【问题标题】:Tidyverse's tidy() function not working in R [duplicate]Tidyverse 的 tidy() 函数在 R 中不起作用 [重复]
【发布时间】:2021-02-13 17:28:21
【问题描述】:

我有一个简单的问题,即 R 中的 tidy() 函数不起作用。我已经安装了 tidyverse 并用library(tidyverse) 加载了它。但是我收到以下错误消息:

Error in tidy(fit1b) : could not find function "tidy"

我在加载包时也遇到了以下冲突(只有“lfe”和“tidyverse”包),但我不确定它们是否导致了问题:

x tidyr::expand() masks Matrix::expand()
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
x tidyr::pack()   masks Matrix::pack()
x tidyr::unpack() masks Matrix::unpack()

【问题讨论】:

    标签: r tidyverse broom


    【解决方案1】:

    您需要的函数来自broom,它不属于tidyverse

    见:

    library(tidyverse)
    ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
    ✔ ggplot2 3.3.2     ✔ purrr   0.3.4
    ✔ tibble  3.0.1     ✔ dplyr   1.0.0
    ✔ tidyr   1.1.0     ✔ stringr 1.4.0
    ✔ readr   1.3.1     ✔ forcats 0.5.0
    ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
    ✖ dplyr::filter() masks stats::filter()
    ✖ dplyr::lag()    masks stats::lag()
    
    tidy(lm(mpg ~ hp,data=mtcars))
    Error in tidy(lm(mpg ~ hp, data = mtcars)) : 
      could not find function "tidy"
    

    如果你加载broom

    library(broom)
    tidy(lm(mpg ~ hp,data=mtcars))
    # A tibble: 2 x 5
      term        estimate std.error statistic  p.value
      <chr>          <dbl>     <dbl>     <dbl>    <dbl>
    1 (Intercept)  30.1       1.63       18.4  6.64e-18
    2 hp           -0.0682    0.0101     -6.74 1.79e- 7
    

    【讨论】:

    • 真的很有帮助,谢谢。你知道为什么 dwplot 显示相同的错误。我用谷歌搜索并找到了“dplyr”库。加载它没有帮助。
    • 找到了。如果有人需要,它被称为“dotwhisker”库。
    猜你喜欢
    • 1970-01-01
    • 2012-07-05
    • 2018-12-07
    • 2014-01-12
    • 1970-01-01
    • 2015-04-16
    • 2019-06-04
    • 2014-11-10
    • 1970-01-01
    相关资源
    最近更新 更多