How to identify the class of a variable within a tidyeval function?

Hi,

How do you identify the class of a variable within a tidyeval function?

The only way I know to do it is to pull the variable into a vector, but that seems quite inefficient

Thanks!
David

I'm posting this to make the discussion more concrete. Comments or questions welcome

library(tidyverse)
classident <- function(data, var) {
  var_ <- enquo(var)
  
  data %>%
    summarise(class = class(!!var_))
}

classident(mtcars,  mpg)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.