With your first example:
> tidy(iris)
Error in var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
Calling var(x) on a factor x is defunct.
So the problem is the factor, and indeed the column Species
that you remove is of class factor:
sapply(iris, class)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> "numeric" "numeric" "numeric" "numeric" "factor"
The reason for that behavior I think is in the warning message:
Data frame tidiers are deprecated and will be removed in an upcoming release of broom.
So you're not supposed to use broom::tidy()
on data frames anymore, and that problem won't be fixed. If you just want to transform a data frame in a tibble, you can use tidyr::tibble()
.
If what you were interested in were the summary statistics, alternatives include base::summary()
and skimr::skim()
(that gives a lot more information). Or to use your own call to dplyr::summarize()
, which also makes more explicit what you're trying to obtain.