-
Notifications
You must be signed in to change notification settings - Fork 375
/
appendix.Rmd
86 lines (70 loc) · 2.83 KB
/
appendix.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# (APPENDIX) Appendix {-}
# Building the book from source
The complete source of the book is available [online](https://github.com/csgillespie/efficientR). 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
1. Install the book dependencies.
```{r eval=FALSE}
# Make sure you are using the latest version of `devtools`
# Older versions do not work.
devtools::install_github("csgillespie/efficientR")
```
1. Clone the efficientR [repository](https://github.com/csgillespie/efficientR)
* See the chapter \@ref(collaboration) on Efficient collaboration for an introduction
to git and github.
1. 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:
```{r eval=FALSE}
# Installs package dependencies shown below
devtools::install_github("csgillespie/efficient",
args = "--with-keep.source")
```
The book depends on the following CRAN packages:
```{r is_travis, echo=FALSE}
## 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)
```
```{r echo=FALSE, warning=FALSE, message=FALSE, eval=(!is_travis)}
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")
```
```{r echo=FALSE, message=FALSE, warning=FALSE}
knitr::kable(pkgs_df)
```
# References {-}