Here is the output that I want from data.table.
library(data.table)
dt_mtcars <- as.data.table(mtcars)
## desired output ----
dt_mtcars[mpg >20
          , .(mean_mpg = mean(mpg)
              ,median_mpg = median(mpg))
          , .(cyl, gear)]
   cyl gear mean_mpg median_mpg
1:   6    4   21.000      21.00
2:   4    4   26.925      25.85
3:   6    3   21.400      21.40
4:   4    3   21.500      21.50
5:   4    5   28.200      28.20
I want to get the output by passing arguments to a function.
processFUN <- function(dt, where, select, group){
  out <- dt[i=eval(parse(text = where))
            ,j=eval(parse(text = select))
            ,by=eval(parse(text = group))]
  return(out)
}
report <- processFUN(dt_mtcars 
                     ,where= "mpg > 20"
                     ,select= ".(mean_mpg = mean(mpg), median_mpg = median(mpg))"
                     ,group= ".(cyl, gear)")
However, I get an error message.
 Error in .(cyl, gear) : could not find function "." 
 
     
     
    