I am completely confused. I have a function which is creating a table go quantiles. My problem, if within the data provided to the function is a column named "species" then I want to group by this column. Otherwise do the same code ungrouped. I get the warning, that this is deprecated but even though, it is strange that all my variables are changing.
I am pretty sure that this is a new behaviour and didn't happened before since I am using this function since 2 years or so without changing it.
Can somebody have a look?
library(dplyr)
set.seed(1)
df<- data.frame(Intensity=rnorm(1000, 25, 3))
class(df)
#> [1] "data.frame"
df_backup <- df
class(df_backup)
#> [1] "data.frame"
my_plotAbundanceRank <- function(data_set) {
quantile_df <-
data_set %>%
dplyr::group_by_at(vars(matches('^species$'))) %>%
dplyr::summarise(`5%`=stats::quantile(log10(Intensity),.05),
`50%`=stats::quantile(log10(Intensity),.50),
`95%`=stats::quantile(log10(Intensity),.95))
}
print(my_plotAbundanceRank(df))
#> # A tibble: 1 x 3
#> `5%` `50%` `95%`
#> <dbl> <dbl> <dbl>
#> 1 1.30 1.40 1.48
class(df)
#> [1] "tbl_df" "tbl" "data.frame"
class(df_backup)
#> [1] "tbl_df" "tbl" "data.frame"
After execution, the class is changing from [1] "data.frame"
to [1] "tbl_df" "tbl" "data.frame"
for all variables, even they are not provided to the function.
I am using dplyr_0.8.0.1
which is pretty new and might cause the problem.
Any ideas?
UPDATE
So I tested with dplyr_0.7.8
and the code is working as expected, so all variables stay data.frame
.
devtools::install_version("dplyr", version = "0.7.8", repos = "http://cran.us.r-project.org")