write_rmd <- function(file, name) { rmd <-templates::templ("--- title: '{{name}}' output: github_document always_allow_html: yes
knitr::opts_chunk$set(echo = FALSE, message=FALSE, warning=FALSE) drake.path<-'~/Dropbox/msandifo/documents/programming/r/twitter/2018/{{name}}/' full.repro<-F library(reproscir) source('./src/settings.R') source('./src/theme.R') source('./src/functions.R') source('./src/plan.R') #load(paste0(drake.path, '/data/data.Rdata')) source('./src/downloads.R')
This repro has no description.
The code base is in r
and is managed within RStudio, using the drake
package, and my reoproscir
package on github
obtained with devtools::install_github('msandifo/reproscir')
. Note this package is very much a work in progress, and while it is installed automagically,it will likely need reinstalling with devtools::install_github('msandifo/reproscir')
.
The code can be executed by opening the Rstudio
project 00x.Rproj
and sourcing drake.R
.
source('drake.R')
Details of the steps invoked by ``drake.R
are summarised below.
source('./src/packages.R')
checks for and automatically installs missing package dependencies
source('./src/settings.R')
sets variables, such as the drake.path
,
source('./src/functions.R')
reads in data processing functions not in reproscir
source('./src/theme.R')
sets the ggplot theme derived from hrbrthemes
source('./src/plots.R')
plot functions source('./src/downloads.R')
directs the download of the relevant data files to be downloaded into the local directory set by
local.path
. By default local.path=NULL
in which case data is downloaded via rappdirs::user_cache_dir()
to a folder in the users cache directory (for macOSX, ~/Library/cache
) to file.path(local.path, aemo)
.
source('./src/plan.R')
defines the drake plan reproplan
with the dependency structure
source('./src/settings.R') source('./src/theme.R') source('./src/functions.R') source('./src/plots.R') source('./src/plan.R') drake::make( reproplan ) config <- drake::drake_config(reproplan) graph <- drake::drake_graph_info(config, group = 'status', clusters = 'imported') drake::render_drake_graph(graph, file='figs/rmd_render_drake.png')
Note that reproplan
porcesses the files downloaded by ./src/downloads.R
, returning merged.data
print(head(readd(merged.data)))
source(drake::make( reproplan ))
source('./src/ouputs.R')
output charts to the ./figs
directory :
```r p00x<-drake::readd(p00x)
```
", name) cat(rmd, file) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.