整理一个 class _lm 的对象
Tidy a object of class _lm
参考
: Get Started With TidyModels
我无法整理模型 class _lm 来整理。新 tidymodel.org 入门的确切代码
使用站点并生成错误。我的猜测是我需要一些软件包更新。
Error: No tidy method for objects of class _lm
这是从网站复制的代码:
library(tidymodels)
library(readr)
urchins <-
# Data were assembled for a tutorial
# at https://www.flutterbys.com.au/stats/tut/tut7.5a.html
read_csv("https://tidymodels.org/start/models/urchins.csv") %>%
# Change the names to be a little more verbose
setNames(c("food_regime", "initial_volume", "width")) %>%
# Factors are very helpful for modeling, so we convert one column
mutate(food_regime = factor(food_regime, levels = c("Initial", "Low", "High")))
#> Parsed with column specification:
#> cols(
#> TREAT = col_character(),
#> IV = col_double(),
#> SUTW = col_double()
#> )
urchins
ggplot(urchins,
aes(x = initial_volume,
y = width,
group = food_regime,
col = food_regime)) +
geom_point() +
geom_smooth(method = lm, se = FALSE) +
scale_color_viridis_d(option = "plasma", end = .7)
lm_mod <-
linear_reg() %>%
set_engine("lm")
lm_fit <-
lm_mod %>%
fit(width ~ initial_volume * food_regime, data = urchins)
lm_fit
tidy(lm_fit)
我推测您正在使用 R 4.0,因为我们看到其他用户也有同样的问题。词汇范围的变化影响了方法的 S3 注册,例如 tidy
方法。您可以查看 somebody having a similar problem here.
我们已经在 parsnip 的开发版本中修复了这个问题,它会尽快提交给 CRAN。在新的 CRAN 版本发布之前,您可以使用
devtools::install_dev("parsnip")
获取新版本。
参考 : Get Started With TidyModels
我无法整理模型 class _lm 来整理。新 tidymodel.org 入门的确切代码 使用站点并生成错误。我的猜测是我需要一些软件包更新。
Error: No tidy method for objects of class _lm
这是从网站复制的代码:
library(tidymodels)
library(readr)
urchins <-
# Data were assembled for a tutorial
# at https://www.flutterbys.com.au/stats/tut/tut7.5a.html
read_csv("https://tidymodels.org/start/models/urchins.csv") %>%
# Change the names to be a little more verbose
setNames(c("food_regime", "initial_volume", "width")) %>%
# Factors are very helpful for modeling, so we convert one column
mutate(food_regime = factor(food_regime, levels = c("Initial", "Low", "High")))
#> Parsed with column specification:
#> cols(
#> TREAT = col_character(),
#> IV = col_double(),
#> SUTW = col_double()
#> )
urchins
ggplot(urchins,
aes(x = initial_volume,
y = width,
group = food_regime,
col = food_regime)) +
geom_point() +
geom_smooth(method = lm, se = FALSE) +
scale_color_viridis_d(option = "plasma", end = .7)
lm_mod <-
linear_reg() %>%
set_engine("lm")
lm_fit <-
lm_mod %>%
fit(width ~ initial_volume * food_regime, data = urchins)
lm_fit
tidy(lm_fit)
我推测您正在使用 R 4.0,因为我们看到其他用户也有同样的问题。词汇范围的变化影响了方法的 S3 注册,例如 tidy
方法。您可以查看 somebody having a similar problem here.
我们已经在 parsnip 的开发版本中修复了这个问题,它会尽快提交给 CRAN。在新的 CRAN 版本发布之前,您可以使用
devtools::install_dev("parsnip")
获取新版本。