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
# R manifest | |
# Manifest type: session | |
# Dependency repositories: 6 | |
# repo: https://cloud.r-project.org | |
# repo: https://bioconductor.org/packages/3.14/bioc | |
# repo: https://bioconductor.org/packages/3.14/data/annotation | |
# repo: https://bioconductor.org/packages/3.14/data/experiment | |
# repo: https://bioconductor.org/packages/3.14/workflows | |
# repo: https://bioconductor.org/packages/3.14/books | |
"name","url","type","branch","subdir","extra","version" |
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
argify = function(expr, recursive = FALSE) { | |
if(is.character(expr)) | |
expr = parse(text = expr) | |
else if(!is.call(expr)) | |
expr = substitute(expr) | |
stopifnot(is.call(expr)) | |
if(recursive && length(expr) > 1) { | |
for(i in 2:length(expr)) { | |
if(is.call(expr[[i]])) | |
expr[[i]] = argify(expr[[i]], TRUE) |
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
findneedle = function(need, hay) { | |
inds = which(hay == need[1L]) | |
i = 2L | |
while(i <= length(need) && length(inds) > 0L) { | |
nval = need[i] | |
## adding the scalars together first reduces the allocs | |
## by 1 saves time if inds is really long | |
inds = inds[hay[(i - 1L) + inds] == nval] |
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
# R manifest | |
# Manifest type: session | |
# Dependency repositories: 5 | |
# repo: https://bioconductor.org/packages/3.5/bioc | |
# repo: https://bioconductor.org/packages/3.5/data/annotation | |
# repo: https://bioconductor.org/packages/3.5/data/experiment | |
# repo: https://bioconductor.org/packages/3.5/extra | |
# repo: https://cran.rstudio.com | |
"name","url","type","branch","subdir","extra","version" | |
"switchrGist","https://cran.rstudio.com/src/contrib","CRAN","trunk",".",NA,"0.2.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
## this worked for me | |
df = data.frame("omg" = factor(sample(1:2, 100, replace=TRUE)), x = rnorm(100), y = rnorm(100)) | |
ggplot(data=df) + aes(x = x, y = y, color = omg) + geom_point() + scale_colour_discrete(guide_legend(title="whaaat?\nok!")) |
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
We set up knitr so it doesn't catch errors, then set | |
`options(error=recover)` to set up R's debug-on-error machinery. | |
We have to do one additional thing, before the options call though: | |
trace the recover function with`sink(NULL)` to turn off the output | |
capturing so the R console is useful when the debugging framework | |
dumps us back into it. This has to happen before the options call | |
because that call grabs the `recover` object and stores it somewhere | |
so setting a trace on recover after the call won't affect the cached | |
version that gets called upon an error. |
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
happyfun = function(pat, txt) { | |
m = gregexpr(pat, txt, perl=TRUE)[[1]]; | |
t = attr(m, "capture.start"); | |
mapply(function(st, end) substr(txt, st, end), | |
st = t, | |
end = t+attr(m, "capture.length")-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
# R manifest | |
# Manifest type: package | |
# Dependency repositories: 5 | |
# repo: http://bioconductor.org/packages/3.1/bioc | |
# repo: http://bioconductor.org/packages/3.1/data/annotation | |
# repo: http://bioconductor.org/packages/3.1/data/experiment | |
# repo: http://bioconductor.org/packages/3.1/extra | |
# repo: http://cran.fhcrc.org | |
"name","url","type","branch","subdir","extra" | |
"http://github.com/gmbecker/fastdigest","fastdigest","http://github.com/gmbecker/fastdigest","git","master",".",NA |
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
test gist contents |
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
col1 <- runif (12^6, 0, 2) | |
col2 <- rnorm (12^6, 0, 2) | |
col3 <- rpois (12^6, 3) | |
col4 <- rchisq (12^6, 2) | |
df <- data.frame (col1, col2, col3, col4) | |
## process the rows | |
## slightly less than 3 times slower than Rcpp example here http://rstatistics.net/strategies-to-speed-up-r-code/ (on my machine) | |
## but written only in R |
NewerOlder