Hello,

I am trying to pass a conditional expression into an expression to be
evaluated when ever an R statement is called.  For example:

get_unique_count <- function(df, select, field){
   uniqs <- unique(subset(df, select)[field])
   return (nrow(uniqs))
}


In this case select is a conditional statement year == 1980, and the
function would be called in the following manner:

library(ggplot2)
get_unique_count(mpg, year==1980, 'manufacturer')

Thank for any help in advance,

-- Adam

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to