- Measuring the speed of nervous system conduction
- And, a tiny lesson in open, transparent, reproducible data science
2017-12-04 09:53:17
We predict that the speed of conduction will be …
# Load R packages library("googlesheets") suppressPackageStartupMessages(library("dplyr")) suppressPackageStartupMessages(library("ggplot2"))
psych260 <- gs_title("psych-260-fall-2017")
## Sheet successfully identified: "psych-260-fall-2017"
psych260 %>% gs_read(ws = "distance") -> distance
## Accessing worksheet titled 'distance'.
## Downloading: 100 B Downloading: 100 B Downloading: 110 B Downloading: 110 B Downloading: 110 B Downloading: 110 B Downloading: 110 B Downloading: 110 B
## Warning: Missing column names filled in: 'X3' [3]
## Parsed with column specification: ## cols( ## participant.id = col_integer(), ## ankleshoulder = col_integer(), ## X3 = col_character(), ## comment = col_character() ## )
dist.hist <- ggplot(data = distance, aes(x=ankleshoulder)) + geom_histogram(bins = 5)
with(distance, summary(ankleshoulder))
## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 124.0 127.0 132.0 132.4 137.0 146.0
# Calculate sum dist.sum = with(distance, sum(ankleshoulder, na.rm = TRUE))
The total distance is 1192 cm.
psych260 %>% gs_read(ws = "time") -> time
## Accessing worksheet titled 'time'.
## Downloading: 120 B Downloading: 120 B Downloading: 120 B Downloading: 120 B Downloading: 120 B Downloading: 120 B Downloading: 120 B Downloading: 120 B
## Warning: Missing column names filled in: 'X4' [4]
## Parsed with column specification: ## cols( ## trial = col_integer(), ## condition = col_character(), ## time = col_double(), ## X4 = col_character(), ## comment = col_character() ## )
# Plot data time.plot = ggplot(data = time, aes(x=trial, y=time, color=condition)) + geom_point() + geom_line()
time %>% filter(condition == "ankle") -> ankle.times time %>% filter(condition == "shoulder") -> shoulder.times time.diff <- data_frame(trial=unique(time$trial), time=ankle.times$time - shoulder.times$time) time.diff.plot = ggplot(data = time.diff, aes(x=trial, y=time)) + geom_point() + geom_line()
time.diff$speed <- (dist.sum)*.01/time.diff$time speed.hist <- ggplot(data = time.diff, aes(x=speed)) + geom_histogram(bins = 5) + xlab("Speed (m/s)")
speed.plot <- ggplot(data = time.diff, aes(x=trial, y=speed)) + geom_point() + geom_line() + ylab("Speed (m/s)")
speed.plot
This document was prepared in RStudio 1.1.383 on 2017-12-04 09:53:24.
sessionInfo()
## R version 3.4.1 (2017-06-30) ## Platform: x86_64-apple-darwin15.6.0 (64-bit) ## Running under: macOS Sierra 10.12.6 ## ## Matrix products: default ## BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib ## LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib ## ## locale: ## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] bindrcpp_0.2 ggplot2_2.2.1 dplyr_0.7.2 ## [4] googlesheets_0.2.2 ## ## loaded via a namespace (and not attached): ## [1] Rcpp_0.12.12 xml2_1.1.1 knitr_1.17 bindr_0.1 ## [5] magrittr_1.5 hms_0.3 munsell_0.4.3 colorspace_1.3-2 ## [9] R6_2.2.2 rlang_0.1.2 plyr_1.8.4 stringr_1.2.0 ## [13] httr_1.3.1 tools_3.4.1 grid_3.4.1 gtable_0.2.0 ## [17] htmltools_0.3.6 lazyeval_0.2.0 openssl_0.9.6 yaml_2.1.14 ## [21] rprojroot_1.2 digest_0.6.12 assertthat_0.2.0 tibble_1.3.3 ## [25] readr_1.1.1 purrr_0.2.3 curl_2.8.1 glue_1.1.1 ## [29] evaluate_0.10.1 rmarkdown_1.6 labeling_0.3 stringi_1.1.5 ## [33] compiler_3.4.1 cellranger_1.1.0 scales_0.5.0 backports_1.1.0 ## [37] jsonlite_1.5 pkgconfig_2.0.1