Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
My common knitr defaults
# My preferred defaults (may be changed in individual chunks)
opts_chunk$set(tidy=FALSE, warning=FALSE, message=FALSE, cache=TRUE,
comment=NA, verbose=TRUE, fig.width=6, fig.height=4)
# Name the cache path and fig.path based on filename...
opts_chunk$set(fig.path = paste("figure/",
gsub(".Rmd", "", knitr:::knit_concord$get('infile')),
"-", sep=""),
cache.path = paste(gsub(".Rmd", "", knitr:::knit_concord$get('infile') ),
"/", sep=""))
# Set plotting to bw plot default, but with transparent background elements.
# Note transparency requires the panel.background, plot.background, and device background all be set!
theme_update(panel.background = element_rect(fill = "transparent", colour = NA),
plot.background = element_rect(fill = "transparent", colour = NA))
# Set a color-blind friendly pallette
# adapted from
cbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7")
# If we have web access (not available from HPC compute nodes) then we can upload figures as we go
opts_knit$set( = socialR::flickr.url)

This comment has been minimized.

Copy link

@kamilkazmierski kamilkazmierski commented Nov 2, 2020

Thank you so much about the tip on setting device background!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.