# 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 = "")
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!
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!
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)
################### ## 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()
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}$$
Inserting images is easy! Place the image in your main folder and use the following syntax (see the RMarkdown file).
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")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.