The complete source of the book is available online. To build the book:
Install the book dependencies.
```r
devtools
devtools::install_github("csgillespie/efficientR") ```
Clone the efficientR repository
RStudio
, open index.Rmd
and click Knit
.Makefile
The book uses datasets stored in the efficient GitHub package, which can be installed (after devtools has been installed) as follows:
# Installs package dependencies shown below devtools::install_github("csgillespie/efficient", args = "--with-keep.source")
The book depends on the following CRAN packages:
## Don't generate bib file on travis is_travis = Sys.getenv("TRAVIS") is_travis = (is_travis == "true") pkgs_df = read.csv("extdata/package_list.csv", header=TRUE)
desc = read.dcf("DESCRIPTION") headings = dimnames(desc)[[2]] fields = which(headings %in% c("Depends", "Imports", "Suggests")) pkgs = paste(desc[fields], collapse = ", ") pkgs = gsub("\n", " ", pkgs) pkgs = strsplit(pkgs, ",")[[1]] pkgs = gsub(" ", "", pkgs) pkgs = gsub("\\(.*)", "", pkgs) # Remove versions from packages ext_pkgs = c("rio", "feather") # issues installing on travis to_install = !pkgs %in% rownames(installed.packages()) if(sum(to_install) > 0){ install.packages(pkgs[to_install]) } if(!all(ext_pkgs %in% rownames(installed.packages()))) { message("Installing rio and feather") install.packages(ext_pkgs, repos="https://cran.rstudio.com/") } i = 1 pkgs = c(pkgs, ext_pkgs) pkgs = pkgs[order(pkgs)] pkgs_df = data.frame(Name = pkgs, Title = NA, cite = NA, version = NA) for(i in seq_along(pkgs)){ f = system.file(package = pkgs[i], "DESCRIPTION") # Title is always on 3rd line title = readLines(f) title = title[grep("Title: ", title)] pkgs_df$Title[i] = gsub("Title: ", "", title) pkgs_df$cite[i] = paste0("[@R-", pkgs[i], "]") pkgs_df$version[i] = as.character(packageVersion(pkgs[i])) } pkgs_df[,2] = paste(pkgs_df[,2], pkgs_df[,3]) pkgs_df = pkgs_df[,-3] write.csv(pkgs_df, "extdata/package_list.csv", row.names = FALSE) knitr::write_bib(pkgs, file="packages.bib")
knitr::kable(pkgs_df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.