3

I have a simple problem in that tidy() function in R is not working. I have tidyverse installed and have loaded it with library(tidyverse). However I get the following error message:

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

I also get the following conflicts when loading the packages (only "lfe" and "tidyverse" packages), but I'm not sure if they are causing the problem:

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()
StupidWolf
  • 45,075
  • 17
  • 40
  • 72
canthandlehtml
  • 83
  • 2
  • 3
  • 9

1 Answers1

8

The function you need is from broom and it's not part of tidyverse.

See:

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"

If you load 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
StupidWolf
  • 45,075
  • 17
  • 40
  • 72