Skip to content

Instantly share code, notes, and snippets.

View famuvie's full-sized avatar

Facundo Muñoz famuvie

View GitHub Profile
loadAllChunksCache <- function(fileContainingChunks,
pathForCache = paste0(sub(".Rmd", "", fileContainingChunks),
"_cache/",
names(which(sapply(c("html", "pdf", "word"),
function(x)dir.exists(paste0(sub(".Rmd", "", fileContainingChunks), "_cache/", x, "/")))))[1],
"/")){
lignesDeNomDeChunk <- grep("^```{r", readLines(fileContainingChunks), perl = TRUE, value = TRUE)
nomsDeChunks <- sapply(strsplit(
sapply(strsplit(
sapply(strsplit(lignesDeNomDeChunk, "{r ", perl = TRUE), function(x) x[[2]]),
@jennybc
jennybc / r-fcsn-in-wild-search.md
Last active January 6, 2020 08:09
Search for "natural" usage of a function across all CRAN packages

What if a function in a package has no examples? Or is poorly exampled? Wouldn't it be nice to find functioning instances of it "in the wild"?

Via Twitter, Noam Ross taught me a clever way to do such searches on GitHub. Put this into the GitHub search box to see people using the llply() function from plyr:

"llply" user:cran language:R

Or just click here.

@rmflight
rmflight / post-commit
Last active March 29, 2024 19:43
useful commit hooks for R package dev
#!/path/2/Rscript
# License: CC0 (just be nice and point others to where you got this)
# Author: Robert M Flight <rflight79@gmail.com>, github.com/rmflight
#
# This is a post-commit hook that after a successful commit subsequently increments the package version in DESCRIPTION
# and commits that. Analogous to the pre-commit at https://gist.github.com/rmflight/8863882, but useful if you only have
# good reasons for not doing it on the pre-commit.
#
# To install it, simply copy this into the ".git/hooks/post-commit" file of your git repo, change /path/2/Rscript, and make