This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"width": 600, | |
"data": { | |
"values": [ | |
{ | |
"__row__": 0, | |
"calendar_month_year": "Dec-23", | |
"concentration_risk_monthly": 0.8 | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json", | |
"width": 600, | |
"data": { | |
"values": [ | |
{ | |
"__row__": 0, | |
"calendar_month_year": "Dec-23", | |
"concentration_risk_monthly": 0.51 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://mathworld.wolfram.com/LookandSaySequence.html | |
library(ggplot2) | |
library(stringi) | |
tic <- Sys.time() | |
len <- 68 | |
s <- rep(NA, len) | |
s[1] <- 1 | |
tm <- rep(NA, len) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prob <- unlist(lapply(1:1000000, function(i){ | |
candles <- sort(runif(2, 0, 1)) | |
cut <- runif(1, 0, 1) | |
(cut > candles[1]) & (cut < candles[2]) | |
})) | |
mean(prob) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## https://youtu.be/094y1Z2wpJg | |
library(tidyverse) | |
collatz <- function(x){ | |
v = c(x) | |
i = 1 | |
while (v[i] != 1){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = ['df dft sdf', 'sd fdggg sd dfhhh d', 'ddd'] | |
def dbllttrwordrev(match): | |
match = match.group() | |
return '<<{}>>'.format(match[::-1]) | |
{ | |
'function': [re.sub("\\b\\w*([a-z])(\\1{2,})\\w*\\b", dbllttrwordrev, x, flags = re.IGNORECASE) for x in text], | |
'lambda': [re.sub("\\b\\w*([a-z])(\\1{2,})\\w*\\b", lambda x: '<<{}>>'.format(x.group()[::-1]) , x, flags = re.IGNORECASE) for x in text] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Load dependencies | |
library(quanteda) | |
library(sentimentr) | |
library(tidyverse) | |
library(lexicon) | |
## Data set from sentimentr package | |
dat <- presidential_debates_2012 | |
dat | |
corp <- corpus(dat, text_field = "dialogue") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Norah's Question: Are there any words that start with chr (phoenetically /k/ /r/) that don't have a a short i sound following it? | |
library(openssl) | |
library(textshape) | |
library(tidyverse) | |
cmudict <- readLines('https://raw.githubusercontent.com/michelleful/ToBoldlyStress/master/stressed_spelling.txt') | |
cmudict7b <- readLines('http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b') %>% tail(-121) %>% head(-4) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
dat <- tibble( | |
x1=c(1,0,0,NA,0,1,1,NA,0,1), | |
x2=c(1,1,NA,1,1,0,NA,NA,0,1), | |
x3=c(0,1,0,1,1,0,NA,NA,0,1), | |
y4=c(1,0,NA,1,0,0,NA,0,0,1), | |
y5=c(1,1,NA,1,1,1,NA,1,0,1), | |
z = LETTERS[1:10] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gridExtra) | |
plot1 <- ggplot(mtcars, aes(x = hp)) + | |
geom_histogram(bins = 10) + | |
labs( | |
y = 'Count of Awesomeness', | |
title = 'Count Histogram' | |
) |
NewerOlder