I have been trying to summarize across numeric columns using dtplyr and summarise(across(where(is.numeric))) and got the error can't rename variables in this context. It took me quite a while to figure out the reason for the error is the usage of a predicate within summarize is not possible with dtplyr.
Is there any substitute for using is.numeric besides for naming all columns?
Thank you
The following code 1) shows error when using predicate, 2) show how the negation does not fail and applies given function to all variables (numeric and non-numeric)
library(ggplot2)
library(data.table)
library(dtplyr)
library(dplyr, warn.conflicts = FALSE)
# fails
diamonds %>% lazy_dt() %>% group_by(color) %>% summarise(across(!where(is.numeric), first))
# applies function to all variables
diamonds %>% lazy_dt() %>% group_by(color) %>% summarise(across(!where(is.numeric), first))
# unlike the equivalent statement using a data frame which only returns the relevant variables
diamonds %>% group_by(color) %>% summarise(across(!where(is.numeric), first))
I have been trying to summarize across numeric columns using dtplyr and
summarise(across(where(is.numeric)))and got the errorcan't rename variables in this context. It took me quite a while to figure out the reason for the error is the usage of a predicate withinsummarizeis not possible with dtplyr.Is there any substitute for using
is.numericbesides for naming all columns?Thank you
The following code 1) shows error when using predicate, 2) show how the negation does not fail and applies given function to all variables (numeric and non-numeric)