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
[internal] Wed Dec 21 08:22:34 2022: | |
(:message "Running language server: (/Library/Frameworks/Python.framework/Versions/3.10/bin/pyright-langserver --stdio)") | |
[client-request] (id:1) Wed Dec 21 08:22:34 2022: | |
(:jsonrpc "2.0" :id 1 :method "initialize" :params | |
(:processId 11322 :rootPath "/Users/cdesjardins/Dropbox/chris/programming/python/python_data_science_handbook/" :rootUri "file:///Users/cdesjardins/Dropbox/chris/programming/python/python_data_science_handbook" :initializationOptions #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data | |
()) | |
:capabilities | |
(:workspace | |
(:applyEdit t :executeCommand | |
(:dynamicRegistration :json-false) |
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
#' @param xbar sample mean | |
#' @param s sample standard deviation | |
#' @param n sample size | |
#' @param mu0 null hypothesis value | |
#' @param ha alternative hypothesis. takes on the value of "less than", "greater than", "not equal to" | |
#' @example | |
#' single.mean.test(xbar = 1.91, s = 1.22, n = 305, mu0 = 2.47, ha = "not equal to") | |
single.mean.test <- function(xbar, s, n, mu0, ha = "not equal to"){ | |
t.stat <- (xbar - mu0) / (s / sqrt(n)) | |
cat("The t-statistic is equal to:", t.stat, "\n") |
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
# modified version of StatBin2 inherits from StatBin, except for an | |
# additional 2nd last line in compute_group() function | |
StatBin2 <- ggproto( | |
"StatBin2", | |
StatBin, | |
compute_group = function (data, scales, binwidth = NULL, bins = NULL, | |
center = NULL, boundary = NULL, | |
closed = c("right", "left"), pad = FALSE, | |
breaks = NULL, origin = NULL, right = NULL, | |
drop = NULL, width = NULL) { |
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
vadj <- .03 | |
hadj <- .015 | |
grid.newpage() | |
vp <- viewport(width=0.85,height=0.85) | |
pushViewport(vp) | |
grid.lines(x = c(0, 1), | |
y = c(0, 0), | |
gp = gpar(fill = "black"), | |
arrow = arrow(angle = 20, type = "closed")) | |
## participants |
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
covid <- read.csv("https://data.cdc.gov/api/views/y5bj-9g5w/rows.csv?accessType=DOWNLOAD&bom=true&format=true%20target=") | |
names(covid)[1] <- "Jurisdiction" | |
library(dplyr) | |
library(ggplot2) | |
ct <- covid %>% | |
group_by(Week, Year) %>% | |
filter(Type == "Unweighted", Jurisdiction != "United States") %>% | |
summarize(totl = sum(Number.of.Deaths)) |
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
--- | |
title: "RR Laura Le" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` | |
<iframe id="inlineFrameExample" |
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
mtcars$vs.f <- ifelse(mtcars$vs == 0, "0", "1") | |
mtcars.0 <- subset(mtcars, vs.f == "0") | |
mtcars.1 <- subset(mtcars, vs.f == "1") | |
coef(lm(mpg ~ cyl * vs.f, data = mtcars)) # association between 1 should be strong | |
coef(lm(mpg ~ cyl, data = mtcars.0)) # association between 0 smaller | |
coef(lm(mpg ~ cyl, data = mtcars.1)) # association between 1 larger | |
cor(mtcars.0$mpg, mtcars.0$cyl) | |
cor(mtcars.1$mpg, mtcars.1$cyl) |
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
Country | Total Score | |
---|---|---|
Spain | 38 | |
Spain | 44 | |
Spain | 42 | |
Spain | 46 | |
Spain | 29 | |
Spain | 8 | |
Spain | 22 | |
Spain | 49 | |
Spain | 32 |
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
# untidyverse | |
# this one is sooooooo hard to type | |
an.agg <- aggregate(bmi ~ an_j + months, | |
FUN = function(x) c(m = mean(x), n = n(x)), | |
data = an.l) | |
# tidyverse | |
# this one makes my fingers sing | |
bmi %>% | |
group_by(an_j) %>% |
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
cleanNAs <- function(x){ | |
if(sum(is.na(x)) == length(x)) { | |
x <- NA | |
} else | |
x <- x[!is.na(x)] | |
x | |
} | |
dat <- read.csv("testing.csv", header = TRUE) | |
dat$clean <- apply(dat, 1, cleanNAs) |
NewerOlder