У меня есть следующий фрейм данных
> df <- dput(df2)
structure(list(Economy = c("FRANCE", "FRANCE", "SPAIN", "SPAIN",
"GREECE", "GREECE", "ITALY", "ITALY", "PORTUGAL", "PORTUGAL"),
ConditionA = c(9, 12, 12, 12, 12, 12, 13, 13, 12, 13), ConditionB = c(16,
16, 18, 21, 27, 27, 30, 36, 36, 36), ConditionC = c(27, 29,
31, 34, 41, 48, 52, 56, 56, 56), ConditionD = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_)), row.names = c(NA, 10L), class = "data.frame
> df2
Economy ConditionA ConditionB ConditionC ConditionD
1 FRANCE 9 16 27 NA
2 FRANCE 12 16 29 NA
3 SPAIN 12 18 31 NA
4 SPAIN 12 21 34 NA
5 GREECE 12 27 41 NA
6 GREECE 12 27 48 NA
7 ITALY 13 30 52 NA
8 ITALY 13 36 56 NA
9 PORTUGAL 12 36 56 NA
10 PORTUGAL 13 36 56 NA
Я хотел бы запустить линейную регрессию каждого условия для каждой страны.
df %>%
dplyr::select(-Economy) %>% # exclude outcome, leave only predictors
map(~lm(.x ~ Economy , data =df, na.action = "na.omit")) %>%
map(summary)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
У меня 188 условий в исходном фрейме данных. Что не так?