Here are some links to resources for working with R Markdown shared for the Code Horizons course.
-
Markdown Live Preview - A useful tool for learning basic Markdown syntax.
| # Example of how to estimate ME inequality measure analytically and via | |
| # bootstrap based on: | |
| # https://sociologicalscience.com/articles-v12-7-115/ | |
| # load libraries ---------------------------------------------------------- | |
| library(palmerpenguins) | |
| library(marginaleffects) | |
| library(tidyverse) |
| ```{r} | |
| #| label: tbl-reg | |
| #| tbl-cap: Models predicting miles per gallon | |
| # build your models here - change these | |
| model1 <- lm(mpg~cyl+disp, data=mtcars) | |
| model2 <- lm(mpg~cyl+disp+hp, data=mtcars) | |
| model3 <- lm(mpg~cyl+disp+hp+wt, data=mtcars) | |
| modelsummary(list(model1, model2, model3), output = "gt", |
| --- | |
| title: "Test" | |
| html_document: | |
| # css: "style.css" | |
| --- | |
| ```{css custom-css, echo=FALSE} | |
| caption { | |
| color: black; | |
| font-size: 1.2em; |
Here are some links to resources for working with R Markdown shared for the Code Horizons course.
Markdown Live Preview - A useful tool for learning basic Markdown syntax.
| # I showed you how you can use wesanderson colors in your ggplots if you want in class. This script breaks | |
| # down how to do that. The first thing you need to do is intall the "wesanderson" library in your project. | |
| # You can do this with the following R command: | |
| install.packages("wesanderson") | |
| # PLEASE NOTE: You only need to install this once per project, so don't put it in a script you are going to run. | |
| # Once it is installed, you can load it with a library call (and lets load ggplot2 at the same time) | |
| library(wesanderson) |
| # put these library calls elsewhere | |
| library(stringr) | |
| library(dplyr) | |
| library(ggplot2) | |
| # A model for testing this out | |
| model_PoliAff2 <- multinom(Poli_Aff~Race_Multi+birth_decade+I(Income/1000)+Education+Gender, | |
| data=anes_combined) | |
| # a function that will give you the average predicted proportions of party affilaition |
| #################################### | |
| # example_script.R | |
| # A basic example script | |
| # Aaron Gullickson | |
| #################################### | |
| # Load Libraries ---------------------------------------------------------- | |
| library(ggplot2) | |
| library(ggthemes) |
| #recoded_variable <- ifelse(true/false statement, replacement if true, original value) | |
| #code missing values | |
| #GSS$god <- ifelse(GSS$GOD==0 | GSS$GOD==8 | GSS$GOD==9, NA, GSS$GOD) | |
| #summary(GSS$god) | |
| #table(GSS$god, GSS$GOD, exclude=NULL) | |
| #code numeric responses as categorical (factor) | |
| GSS$god <- factor(GSS$GOD, | |
| levels=1:6, |
| metro <- aggregate(cbind(pop_total, | |
| pop_nh_white, | |
| pop_nh_black)~met2013+met_name, | |
| data=tracts, sum) |
| ## Reading in data adventures! | |
| library(readr) | |
| library(haven) | |
| library(readxl) | |
| # Reading in Text Files --------------------------------------------------- | |
| #read in basic csv |