-
Notifications
You must be signed in to change notification settings - Fork 19
/
README.Rmd
214 lines (181 loc) · 9.7 KB
/
README.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Rockerverse
<!-- badges: start -->
[![Launch RStudio Binder](http://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/nuest/rockerverse-paper/master?urlpath=rstudio)
[![Build Status](https://travis-ci.org/nuest/rockerverse-paper.svg?branch=master)](https://travis-ci.org/nuest/rockerverse-paper)
<!-- badges: end -->
Article about everything related to containers and R, originally based on [this blog post](http://bit.ly/docker-r) and now **available as a preprint on arXiv.org: https://arxiv.org/abs/2001.10641** ([read as HTML](https://www.arxiv-vanity.com/papers/2001.10641/)).
**Current draft: https://nuest.github.io/rockerverse-paper/master.pdf**
```{r hexSticker, message=TRUE, warning=FALSE, cache=TRUE, include=FALSE}
library("magick")
library("here")
# https://commons.wikimedia.org/wiki/File:NASA-HS201427a-HubbleUltraDeepField2014-20140603.jpg
if(!file.exists("universe.png")) {
universe <- magick::image_read("https://upload.wikimedia.org/wikipedia/commons/6/69/NASA-HS201427a-HubbleUltraDeepField2014-20140603.jpg")
magick::image_write(universe, here("universe.png"))
}
magick::image_read("https://avatars2.githubusercontent.com/u/9100160?s=200&v=4") %>%
magick::image_scale("2100x2100") %>%
magick::image_channel("Matte") %>%
image_negate() %>%
magick::image_border("black", "150x0") %>%
magick::image_write(here("rocker_mask.png"))
# does not work: image_composite(universe, rockerLogoMask, operator = "CopyOpacity", compose_args = "-composite -alpha Off")
system2("convert", c(here("universe.png"), here("rocker_mask.png"),
"-alpha Off",
"-compose CopyOpacity",
"-composite",
here("whaleverse.png")))
library("sysfonts")
if(!file.exists(here::here("FinalFrontierOldStyle-8Pg.ttf"))) {
stop("Download font Final Frontier Old Style, e.g. from https://www.fontspace.com/allen-r-walden/final-frontier-old-style and put the file in the repo root.")
}
sysfonts::font_add("finalfrontier", here::here("FinalFrontierOldStyle-8Pg.ttf"))
library("hexSticker")
factor <- 1 # for print: 4
hexSticker::sticker(here::here("whaleverse.png"), package = "ROCKERVERSE",
p_family = "finalfrontier",
p_size = 29 * factor, p_y = 1.3,
s_x = 0.97, s_y = 0.95, s_width = 1,
h_fill = "#000000", h_color = "#ffffff",
url = "github.com/nuest/rockerverse-paper",
u_color = "#ffffff", u_size = 4 * factor,
filename = here::here(ifelse(
factor == 1,
"rockerverse.png",
paste0("rockerverse_", 300 * factor, "dpi.png"))),
dpi = 300 * factor)
#file.remove(c(here("universe.png"), here("whaleverse.png"), here("rocker_mask.png")))
```
![Rockerverse hex sticker](rockerverse.png)
The hex sticker uses the font [Final Frontier Old Style](https://www.fontspace.com/allen-r-walden/final-frontier-old-style) and the [Hubble Ultra-Deep Field](https://en.wikipedia.org/wiki/Hubble_Ultra-Deep_Field) combined with the Docker logo as background.
## Render the manuscript with Docker
**Local build**
```bash
docker build --tag rockerverse-paper --file .binder/Dockerfile .
docker run -i -v $(pwd):/rockerverse --user $UID rockerverse-paper Rscript -e 'setwd("/rockerverse"); rmarkdown::render("rockerverse.Rmd")'
```
**Image from Docker Hub**
```bash
docker run -i -v $(pwd):/rockerverse --user $UID nuest/rockerverse-paper Rscript -e 'setwd("/rockerverse"); rmarkdown::render("rockerverse.Rmd")'
```
## Not included projects and packages
- `rize`, because discontinued, see #35
- `docker` ([https://bhaskarvk.github.io/docker](https://bhaskarvk.github.io/docker) has been removed from CRAN, seems unmaintained by authors
- https://github.com/svlentink/dockerfiles/blob/master/svlentink/r-base-alpine/Dockerfile because the Alpine image is quite a trivial one
- https://github.com/jlisic/R-docker-centos because CentOS images are also provided by R-hub
- `sevenbridges` includes several Dockerfiles and documentation about using images, and also seems to use Docker in the built workflows but via other tools, not directly, https://sbg.github.io/sevenbridges-r/, https://github.com/sbg/sevenbridges-r/search?p=4&q=docker&unscoped_q=docker
- https://github.com/rocker-jp because it seems to have stalled soon after inception
- https://github.com/thomasp85/fiery because no examples/docs for Docker (though probably trivial anyway)
- [RStudio Connect](https://rstudio.com/products/connect/) because while it does use a similar mechanism to seperate processes, it does _not_ use Docker and the comparison would require a lot of background explanation, and not all details are available because the software is proprietary
- https://github.com/ecohealthalliance/reservoir is an invididual specific data science image container for a group - add if it fits
- https://itsalocke.com/blog/building-an-r-training-environment/ (one single container for many users in teaching, uses rocker/tidyverse)
## Helpers
The [README.Rmd](README.Rmd) file's source includes some useful little code snippets, e.g. count words or get a list of all contributor's GitHub handles.
```{r word_stats, eval=FALSE, include=FALSE}
# devtools::install_github("benmarwick/wordcountaddin", type = "source", dependencies = TRUE)
wordcountaddin::readability(here::here("rockerverse.Rmd"))
wordcountaddin::text_stats(here::here("rockerverse.Rmd"))
```
```{r preprint_pdf, eval=FALSE, include=FALSE}
# run this chunk, get the PDF, then revert changes in touched files
library("rmarkdown")
library("rticles")
unlink('manuscript_cache', recursive = TRUE)
# function is a copy of rticles::rjournal_article() but...
# - using RJWrapper_preprint_template.tex (which includes header.tex commands)
# - directly referencing unexported functions from rticles
# - direclty setting the keep_tex option
rjournal_style_preprint <- function (..., citation_package = "natbib") {
rmarkdown::pandoc_available("2.2", TRUE)
base <- rticles:::pdf_document_format("rjournal_article", highlight = NULL,
citation_package = citation_package, ...)
base$pandoc$to <- "latex"
base$pandoc$ext <- ".tex"
base$pandoc$keep_tex <- TRUE # added
base$post_processor <- function(metadata, utf8_input, output_file,
clean, verbose) {
filename <- basename(output_file)
if (filename != (filename2 <- gsub("_", "-", filename))) {
file.rename(filename, filename2)
filename <- filename2
}
m <- list(filename = xfun::sans_ext(filename))
h <- rticles:::get_list_element(metadata, c("output", "rticles::rjournal_article",
"includes", "in_header"))
h <- c(h, if (length(preamble <- unlist(metadata[c("preamble",
"header-includes")]))) {
f <- tempfile(fileext = ".tex")
on.exit(unlink(f), add = TRUE)
xfun::write_utf8(preamble, f)
f
})
#t <- find_resource("rjournal_article", "RJwrapper.tex")
t <- here::here("RJwrapper_preprint_template.tex")
rticles:::template_pandoc(m, t, "RJwrapper.tex", h, verbose)
tinytex::latexmk("RJwrapper.tex", base$pandoc$latex_engine,
clean = clean)
}
base$knitr$opts_chunk$comment <- "#>"
hilight_source <- rticles:::knitr_fun("hilight_source")
hook_chunk = function(x, options) {
if (rticles:::output_asis(x, options))
return(x)
paste0("```{=latex}\n\\begin{Schunk}\n", x, "\\end{Schunk}\n```")
}
hook_input <- function(x, options) paste(c("\\begin{Sinput}",
hilight_source(x, "sweave", options), "\\end{Sinput}",
""), collapse = "\n")
hook_output <- function(x, options) paste("\\begin{Soutput}\n",
x, "\\end{Soutput}\n", sep = "")
base$knitr$knit_hooks <- rticles:::merge_list(base$knitr$knit_hooks,
list(chunk = hook_chunk, source = hook_input, output = hook_output,
message = hook_output, warning = hook_output, plot = knitr::hook_plot_tex))
base
}
rmarkdown::render("rockerverse.Rmd", output_format = rjournal_style_preprint())
file.rename("RJwrapper.pdf", "rockerverse-preprint.pdf") # file for own archival
# For submission to arXiv:
# 1. Copy the following files into a new folder:
# - figures/*
# - rockerverse.tex
# - RJournal.sty
# - rockerverse.bib
# - RJwrapper.tex
# 2. Run pdfLaTeX directly on RJwrapper.tex (works with RStudio)
# 3. Zip the following files and submit to arXiv:
# - /figures
# - rockerverse.tex
# - RJournal.sty
# - RJwrapper.bbl
# - RJwrapper.tex
```
```{r collab_emails, eval=FALSE, include=FALSE}
front_matter <- rmarkdown::yaml_front_matter("rockerverse.Rmd")
emails <- sapply(X = front_matter$author, FUN = function(a) { a$email })
cat(emails, sep = "\n")
```
```{bash collab_handles, eval=FALSE, include=FALSE}
cat rockerverse.Rmd | grep ' # https://github.com/' | sed 's| # https://github.com/|@|'
```
```{r submission_zipfile, eval=FALSE, include=FALSE}
# Please upload a zip file of the directory containing a motivating letter (in PDF format) if required, the sources of your article; the *.tex, *.bib and *.R files should have the same file name before the extension, which should be your last or family name in lower-case letters, or the last or family names of the authors joined using hyphens. Your title should not include dashes or hyphens. Make sure to also include RJwrapper.tex and RJwrapper.pdf.
zip::zip("rockerverse.zip", c("rockerverse.tex",
"rockerverse.bib",
"rockerverse.R",
"figures/orcid.pdf",
"figures/Rlogo.pdf",
"RJwrapper.tex",
"RJwrapper.pdf"))
```