(APPENDIX) Appendix {-}

Building the book from source

The complete source of the book is available online. To build the book:

  1. Install the latest version of R
    • If you are using RStudio, make sure that's up-to-date as well
  2. Install the book dependencies.

    ```r

    Make sure you are using the latest version of devtools

    Older versions do not work.

    devtools::install_github("csgillespie/efficientR") ```

  3. Clone the efficientR repository

  4. See the chapter \@ref(collaboration) on Efficient collaboration for an introduction to git and github.
  5. If you are using RStudio, open index.Rmd and click Knit.
    • Alternatively (for mainly Linux users) you can use the bundled Makefile

Package dependencies

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)

References {-}



akrmenec/Effic_R_bk documentation built on May 28, 2019, 4:53 p.m.