You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
others will have better answers for this odd behavior but in the meantime I
think this will wrk
outcomes |>
map(
~lm_lin(.x |> paste(" ~ treatment") |> as.formula(), covariates = ~
cov, data = df) |>
tidy() |>
mutate(outcome = .x)
) |> bind_rows()
On Wed, Oct 16, 2024 at 3:50 PM Ben Fifield ***@***.***> wrote:
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()
—
Reply to this email directly, view it on GitHub
<#413>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADBE57L6Z3GDIKK3USZ2HEDZ3ZVL7AVCNFSM6AAAAABQBQ3NZ2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4TCOJWGUYTQNQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
I'm attempting to
map()
over a series of outcomes and applylm_lin()
to each outcome separately with a uniform set of control variables. However, when I do, I get the error:This does not happen when using
lm_robust()
, which runs fine. I've included a reproducible example below:The text was updated successfully, but these errors were encountered: