Distributing OES Functions
This package divides the work of plotting treatment and control outcomes into two steps:
oes_prep()
to create a tidy data table of results
to be plotted;oes_plot()
to plot the tidy data object created by
oes_prep()
.The sample session below installs and uses the package functions.
You only need to install the package once (per update).
First, provide the path to the tar.gz:
# Try installing straight from the web:
<- "https://github.com/gsa-oes/oesr/blob/main/oesr_0.0.1.tar.gz"
tar.gz_path
# If this fails, download the tar.gz, and provide the path to the tar.gz:
# (This must be specific to where you downloaded/saved the file.)
# (If the .gz extension is removed, just use .tar.)
<- "~/Desktop/oesr_0.0.1.tar.gz" tar.gz_path
Then, install the package:
install.packages(tar.gz_path, repos = NULL, type = "source")
Then, load and attach the package (and, for now, needed
tidyverse
):
library(oesr)
library(tidyverse)
Then, use it to plot a simulated treatment effect:
# Simulate some data yourself:
<- tibble(tr = rbinom(100, 1, 0.4), y = rnorm(100) + tr)
df <- lm(y ~ tr, data = df)
lm_out
# Plot with OES style, specifying treatment `vars`:
%>%
lm_out oes_prep() %>%
oes_plot(treatment_vars = "tr")
# Use data included in the package:
data("df_oes")
<- lm(y1 ~ x1, df_oes)
fit
# Plot with OES style, specifying treatment `arms`:
%>%
fit oes_prep() %>%
oes_plot(treatment_arms = 1)
# View the help file in R:
help(oes_plot)
grid.Call()
Lato font
error?If you get an error like
1: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "Lato"
then install the Lato font.
To get the Lato font, download it from https://fontmeme.com/fonts/lato-font/.
Then, on macOS,
+
sign to add a font, and point the
selection dialogue to the “lato” folder you downloaded.grid.Call()
polygon error?If you get an error that says
grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, polygon edge not found
,
try reinstalling X11 from https://www.xquartz.org/, then reinstalling
the ggplot2
package.