Skip to content

Commit

Permalink
Actually formula not required
Browse files Browse the repository at this point in the history
  • Loading branch information
steffilazerte committed Oct 11, 2024
1 parent e1077db commit 998fcf0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 19_Quasiquotation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ vars <- data.frame(x = c("hp", "hp"),
x_sym <- syms(vars$x)
y_sym <- syms(vars$y)
formulae <- map2(x_sym, y_sym, \(x, y) formula(expr(!!y ~ !!x)))
formulae <- map2(x_sym, y_sym, \(x, y) expr(!!y ~ !!x))
formulae
models <- map(formulae, \(f) expr(lm(!!f, data = mtcars)))
summary(eval(models[[1]]))
Expand All @@ -357,7 +357,7 @@ lm_df <- function(df, data) {
y_sym <- map(df$y, as.symbol)
data <- enexpr(data)
formulae <- map2(x_sym, y_sym, \(x, y) formula(expr(!!y ~ !!x)))
formulae <- map2(x_sym, y_sym, \(x, y) expr(!!y ~ !!x))
models <- map(formulae, \(f) expr(lm(!!f, !!data)))
map(models, \(m) summary(eval(m)))
Expand Down

0 comments on commit 998fcf0

Please sign in to comment.