Skip to content

Instantly share code, notes, and snippets.

@RobWiederstein
Last active March 26, 2021 22:06
Show Gist options
  • Save RobWiederstein/b153a853550f42c1378569b06efd49f7 to your computer and use it in GitHub Desktop.
Save RobWiederstein/b153a853550f42c1378569b06efd49f7 to your computer and use it in GitHub Desktop.
Hugo archetype for long form R blog post
title author date slug categories tags layout draft bibliography csl link-citations nocite header repo summary
layouts/post/single
false
packages.bib
../blog.bib
../ieee-with-url.csl
true
@R-base, @R-blogdown, @R-tidyverse
image alt caption
By default, Hugo automatically takes the first 70 words of your content as its summary and stores it into the `.Summary` page variable for use in your templates. You may customize the summary length by setting `summaryLength` in your site configuration *or* you can set it in the front matter.
## Load frequently used packages for blog posts
packages <- c(
      'devtools', #for session info
      'ggthemes', #for plots
      'blogdown'
)
lapply(packages, function(x) {
  if (!requireNamespace(x)) install.packages(x)
  library(x, character.only = TRUE)
})
## Do not break chunk line
## Do not use spaces or periods "." or underscores "_"
## set options for knitr
knitr::opts_chunk$set(
  comment = '',
  fig.width = 6,
  fig.asp = .8,
  fig.align="center",
  message=F,
  error=F,
  warning=F,
  tidy=T,
  comment='',
  cache=T,
  dev='svg',
  echo=F
)
#from ggthemes
library(ggplot2); theme_set(ggthemes::theme_fivethirtyeight())
# color blind friendly palette from http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
cbPalette <- c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7", "#000000")
# write packages used to bib in current directory
knitr::write_bib(.packages(), "./packages.bib")
data(mtcars)
mtcars$cyl <- factor(mtcars$cyl)
p <- ggplot(mtcars, aes(mpg, hp, group = cyl, colour = cyl))
p <- p + scale_color_manual(values = cbPalette)
p <- p + geom_point(size = 2)
p <- p + ggtitle("mtcars")
p

(Describe the problem.)

(Who else has worked on this problem? What did they find?)

(What data did you use, where did you get it?)

This blog post was made possible thanks to:

The views, analysis and conclusions presented within this paper represent the author’s alone and not of any other person, organization or government entity. While I have made every reasonable effort to ensure that the information in this article was correct, it will nonetheless contain errors, inaccuracies and inconsistencies. It is a working paper subject to revision without notice as additional information becomes available. Any liability is disclaimed as to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause. The author(s) received no financial support for the research, authorship, and/or publication of this article.

# system & package info
options(width = 120)
session_info()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment