About

About this site

Welcome to the EARN code library, a resource dedicated to the pursuit of economic and racial justice.

This library is intended to be a hub for generating and sharing research ideas, enhancing data analysis accessibility and transparency, and fostering collaboration.

On this site, you will find coding examples, commonly used EPI/EARN methodologies for economic analysis, coding resources, and beyond. Most importantly, user contributions are warmly welcomed!

User code submissions

Have a coding sample you would like to submit to the EARN code library? Contact dperez@epi.org

Components of a code library submission are:

  1. Description​

  2. Code file(s)​

  3. Supplementary data​

  4. Output example

  5. Author contact information

Happy coding!

# A heart-shaped scatterplot

# Load highcharter library
library(highcharter)

# Generate heart-shaped data
t <- seq(0, 2 * pi, by = 0.01)
x <- 16 * sin(t)^3
y <- 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)

# Create our data frame
df <- data.frame(x, y)

# Create highcharter plot
highchart(type = "chart") %>% 
  hc_add_series(data = df, type = "scatter", color = "red", marker = list(radius = 2)) %>% 
  hc_xAxis(min = -20, max = 20) %>% 
  hc_yAxis(min = -20, max = 15) %>% 
  hc_chart(backgroundColor = "transparent") %>% 
  hc_legend(enabled = FALSE)
Back to top