This file contains hidden or 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
| ## simulate a cross, using genetic map from a CSV file | |
| # read map.csv | |
| maptab <- read.csv("map.csv") | |
| # convert to map object | |
| pos <- maptab[,3] | |
| names(pos) <- maptab[,1] | |
| chr <- maptab[,2] | |
| map <- split(pos, chr) |
This file contains hidden or 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
| sapply(read.csv("test1.csv"), is.numeric) # 2nd column is factor | |
| sapply(read.csv("test2.csv"), is.numeric) # both columns numeric |
This file contains hidden or 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
| # simulate some data and run anova with ranks + Kruskal-Wallis | |
| k <- sample(1:3, 100, repl=TRUE) | |
| eff <- (1:10)/10 | |
| pval <- matrix(nrow=length(eff), ncol=2) | |
| dimnames(pval) <- list(as.character(eff), c("anova", "k-w")) | |
| for(i in seq(along=eff)) { | |
| y <- k*eff[i] + rt(length(k), 3) # residuals ~ t(df=3) | |
| pval[i,1] <- anova(lm(rank(y) ~ factor(k)))[1,5] |
This file contains hidden or 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
| # these behave badly | |
| read.csv("ragged.csv") | |
| data.table::fread("ragged.csv") | |
| (max_n_col <- max(sapply(strsplit( scan("ragged.csv", what=character()), ","), length))) |
This file contains hidden or 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
| > test() | |
| Loading required package: testthat | |
| Testing aRxiv | |
| Loading aRxiv | |
| arxiv_errors : ... | |
| arxiv_search in batches : .. | |
| cleaning the records : ................... | |
| search range of dates : .... | |
| basic searches : ......... | |
| sort_by and sort_order args work : ...1 |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <feed xmlns="http://www.w3.org/2005/Atom"> | |
| <link | |
| href="http://arxiv.org/api/query?search_query%3Dti%3Adeconvolution%20AND%20submittedDate%3A%5B199001010000%20TO%20201409062400%5D%26id_list%3D%26start%3D0%26max_results%3D2" | |
| rel="self" type="application/atom+xml"/> | |
| <title type="html">ArXiv Query: search_query=ti:deconvolution AND | |
| submittedDate:[199001010000 TO | |
| 201409062400]&id_list=&start=0&max_results=2</title> | |
| <id>http://arxiv.org/api/PmrTD7mnJhK1VVvONMZIkrVVdAg</id> | |
| <updated>2014-09-09T00:00:00-04:00</updated> |
This file contains hidden or 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
| A regular code chunk: | |
| ```{r regular} | |
| data(cars) | |
| summary(cars) | |
| ``` | |
| A verbatim code chunk: |
This file contains hidden or 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
| options(show.signif.stars=FALSE, scipen=10, htmlhelp=TRUE) | |
| options(width=115, repos="http://cran.rstudio.com", | |
| CRAN = "http://cran.rstudio.com", | |
| browserNLdisabled = TRUE, | |
| deparse.max.lines = 2) | |
| if (interactive()) { | |
| suppressMessages(require(devtools)) | |
| } | |
| options(error= function() cat(" \\\ \n \\\ |
This file contains hidden or 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
| # convert c("female", "Male") to c(0,1) | |
| # magrittr is way nicer than nested function calls | |
| convert_sexcodes <- | |
| function(codes) | |
| { | |
| require(magrittr) | |
| tolower(codes) %>% |
This file contains hidden or 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
| # if laundry contains n_pair pairs of socks and n_sing singletons, | |
| # how many socks to draw to get first pair? | |
| sim_socks <- | |
| function(n_pair=21, n_sing=3, n_sim=100000) | |
| { | |
| socks <- c(rep(1:n_pair, 2), n_pair+(1:n_sing)) | |
| # replicate(n_sim, min(which(duplicated(sample(socks))))) | |
| library(magrittr) |