12666727b9
12666727b9

Reputation: 1139

map() function error: Error: Can't convert a two-sided formula to a function

I've got the coefficients related to some linear mixed models and stored into a list in the following way:

models_list_1 <- data_long %>%
  group_by(signals) %>%
  do(fit = lmerTest::lmer(value ~ A*B + (1 |C), data = .)) %>% 
  pull(fit) %>% 
  lapply(., function(x) summary(x)$coefficients) %>% 
  setNames(unique(data_long$D))

Since I'm interested to reproduce results iteratively into some table, I'm trying running the follwing code

models_list_1 %>%  
  map(.x ~broom::tidy() %>%
    flextable::flextable()
)

But getting back this error

Error: Can't convert a two-sided formula to a function

Does anyone know how to correct syntaxis?

Upvotes: 1

Views: 1574

Answers (1)

danlooo
danlooo

Reputation: 10637

You need to start the formula with ~ and not with .x using map:

models_list_1 %>%  
  map(
    ~ .x %>% broom::tidy() %>% pull(x) %>% as_tibble() %>% flextable::flextable()
  )

Upvotes: 2

Related Questions