简体   繁体   English

整理一个 object 的 class _lm

[英]Tidy a object of class _lm

Reference: Get Started With TidyModels参考: TidyModels 入门

I can not tidy a model of class _lm to tidy.我无法整理 class _lm 的 model 来整理。 The exact code of the new tidymodel.org Get Started site is used and generates an error.使用新的 tidymodel.org 入门网站的确切代码并生成错误。 My guess is that there is some package update I need.我的猜测是我需要一些 package 更新。

Error: No tidy method for objects of class _lm

Here is the code as copied from the site:以下是从网站复制的代码:

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)

I am surmising that you are working in R 4.0 because we have seen other users have this same problem.我推测您正在使用 R 4.0,因为我们已经看到其他用户也有同样的问题。 There was a change in lexical scoping that impacts S3 registration of methods such as the tidy method.影响 S3 注册方法(例如tidy方法)的词汇范围发生了变化。 You can check out somebody having a similar problem here .您可以在这里查看遇到类似问题的人

We have fixed this problem in the dev version of parsnip and it will be submitted to CRAN ASAP.我们已经在欧洲防风草的开发版中解决了这个问题,它将尽快提交给 CRAN。 Until a new CRAN release, you can use在新的 CRAN 版本发布之前,您可以使用

devtools::install_dev("parsnip")

to get the new version.获取新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM