|

# Set initial knitr options
knitr::opts_chunk$set(eval = TRUE, echo = FALSE,
                      fig.align = "center",
                      fig.asp = 0.7,
                      dpi = 300,
                      out.width = "80%",
                      fig.pos = "!H",
                      out.extra = "")

Problem 1: Escaping the Shire

Solving problem sets will be a weekly ritual at IHEID if you are taking quantitative courses at the Graduate Institute.{iheiddown}'s problem set template lets you focus on solving the problem set rather than wasting time on formatting [@iheiddown2020]. Furthermore, since your documents will be written in RMarkdown, you won't need to learn the more complex Latex syntax. Finally, it allows you to code and interpret the your results at the same time which will again speed up your workflow!

Problem 2: Hiding in forests

Your problem sets will contain some text, probably the solution to a strange mathematical model and maybe even some pretty graphs. The good news is that you can type that really easily in your RMarkdown file!

Tables

The following example shows a simple way to estimate several models and summarize them in a clear way using the {modelsummary} package.

####################
## Tables Example ##
####################

# Loading the required packages
library(modelsummary)
library(kableExtra)
library(gt)

#Extracting example data
url <- "https://vincentarelbundock.github.io/Rdatasets/csv/HistData/Guerry.csv"
dat <- read.csv(url)

# Creating a list of the different models
models <- list(
  "OLS 1"     = lm(Donations ~ Literacy + Clergy, data = dat),
  "Poisson 1" = glm(Donations ~ Literacy + Commerce,
                    family = poisson,
                    data = dat),
  "OLS 2"     = lm(Crime_pers ~ Literacy + Clergy, data = dat),
  "Poisson 2" = glm(Crime_pers ~ Literacy + Commerce,
                    family = poisson,
                    data = dat),
  "OLS 3"     = lm(Crime_prop ~ Literacy + Clergy, data = dat)
)

# Creating a summary of the different models
modelsummary(models)

Graphs

###################
## Graph Example ##
###################

library(ggplot2)
ggplot(mtcars, aes(mpg, wt)) +
  geom_point() +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 scatterplot example",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by {iheiddown}") + 
  theme_iheid()

Problem 3: Resisting the power of the Ring

Writing equations is straightforward too! They follow the standard Latex syntax as shown below. Also see this great guide for a more comprehensive overview of the math syntax in Latex.

$$ E("Escaping"|"Magic") = \frac{a}{b}$$

Problem 4: Melting things in volcanoes

Inserting images is easy! Place the image in your main folder and use the following syntax (see the RMarkdown file).

Ideal place for melting rings

Appendix:

Note that you can reference previous code chunks at the end of the code for full transparency. This is a good way to avoid cluttering your main body with code while still allowing your reader to see the code you executed to get your results. Let us demonstrate this feature by inserting the un-evaluated code of all chunks used in this document.


################################
## Citing all loaded packages ##
################################
knitr::write_bib(c(.packages(), "bookdown"), "packages.bib")

References:



Try the iheiddown package in your browser

Any scripts or data that you put into this service are public.

iheiddown documentation built on Nov. 10, 2022, 5:52 p.m.