-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
Description
I'm attempting to map() over a series of outcomes and apply lm_lin() to each outcome separately with a uniform set of control variables. However, when I do, I get the error:
Error in `map()`:
ℹ In index: 1.
Caused by error in `sym()`:
! could not find function "sym"
Run `rlang::last_trace()` to see where the error occurred.
This does not happen when using lm_robust(), which runs fine. I've included a reproducible example below:
library(tidyverse)
library(estimatr)
N = 100
df <- data.frame(
outcome_a = rbinom(N, 1, .5),
outcome_b = rbinom(N, 1, .5),
treatment = rbinom(N, 1, .5),
cov = rbinom(N, 1, .5)
)
outcomes <- c("outcome_a", "outcome_b")
# Works
outcomes |>
map(
~lm_robust(!!sym(.x) ~ treatment + cov, data = df) |>
tidy() |>
mutate(outcome = .x)
) |> bind_rows()
# Does not work
outcomes |>
map(
~lm_lin(!!sym(.x) ~ treatment, covariates = ~ cov, data = df) |>
tidy() |>
mutate(outcome = .x)
) |> bind_rows()
Reactions are currently unavailable