Statistical distributions

Comparing distributions

## use rnorm to simulate random deviates from a normal distribution

## use runif to simulate random deviates from a uniform distribution

## create historgrams using base plot functions

## create density plots using base plot functions

## create histograms using ggplot2

## create desnity plots using ggplot2

Template for comparing census data

library(ggplot2)
library(tidycensus)
library(sf)
library(dplyr)

## load api key here if necessary

## get income data from the census
us_data <- get_acs(geography = "county",
                   variables = "B19013_001",
                   geometry = TRUE,
                   cb = TRUE)

## get state fips as its own variable
us_data$state <- substr(us_data$GEOID, 1, 2)

## filter by state (get two states of your choice)

## create a histogram of each with ggplot2

## create a density plot of both on the same grid, then modify colors,
## transparency, etc.

## create a violin plot