1
purrr와 선형 회귀 모델을 업데이트, 그러나 이것은 다음과 같은 오류가 발생합니다 :업데이 트와 나는 <code>map</code> 울어 내부 <code>update</code> α- 함수를 사용하여 <code>lm</code> - 모델을 업데이트 할
이mtcars %>% group_by(cyl) %>%
nest() %>%
mutate(lm1 = map(data, ~lm(mpg ~ wt, data = .x)),
lm2 = map(lm1, ~update(object = .x, formula = .~ . + hp)))
Error in mutate_impl(.data, dots) :
Evaluation error: cannot coerce class ""lm"" to a data.frame.
이 사람이 나를 도울 수를 이 문제? 나는이 오류에 대해 혼란 스럽다. 이것은 완전히 작동합니다 :
mtcars %>% group_by(cyl) %>%
nest() %>%
mutate(lm1 = map(data, ~lm(mpg ~ wt, data = .x)),
lm2 = map_dbl(lm1, ~coefficients(.x)[1]))