This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Call rmarkdown::render to create a preview version of a Rmd | |
#' | |
#' This function is intended to be used interactively to create a preview | |
#' version of a Rmd (e.g. compile a chapter of a bookdown project to docx). | |
#' By default, it renders the file currently opened in the RStudio source | |
#' editor, and saves the output to a subfolder called "preview". | |
#' | |
#' The default format is html. The argument word = TRUE will change the output | |
#' format to docx, and using pdf = TRUE will create PDF output. | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(arrow) | |
library(duckdb) | |
# install.packages(c("dplyr", "arrpw", "duckdb", "nycflights13")) | |
## Export the nycflights13 dataset to arrow format ---- | |
nycflights13::flights |> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sf) | |
library(ggplot2) | |
# Data from https://www.geoboundaries.org/index.html#getdata | |
de2 <- read_sf("data/geoBoundaries-DEU-ADM2-all/geoBoundaries-DEU-ADM2_simplified.shp") | |
# Extract Munich and Berlin to separate objects | |
munich <- dplyr::filter(de2, DistrictCo == "09162") | |
berlin <- dplyr::filter(de2, DistrictCo == "11000") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read_chunk_Rmd <- function(path, ...) { | |
f_tmp <- tempfile() | |
knitr::purl(input = path, output = f_tmp) | |
on.exit(file.remove(f_tmp)) | |
knitr::read_chunk(f_tmp, ...) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
## Automatic rules ---- | |
################################################################################ | |
# First problem on windows: where to find Rscript if not on path | |
# RSCRIPT = "C:/Program Files/R/R-3.4.2/bin/x64/Rscript" --verbose | |
RSCRIPT = "Rscript" --verbose | |
# R files with Rout as target |