Would:
tapply(mpg,list(year,manufacturer), function(x) length(unique(x)))
do what you are trying to accomplish? Or do you need very specific subsets?
If so, you can do:
year<-c(rep(1980,4),rep(1981,4))
manufacturer<-rep(c('A','B'),4)
mpg<-sample(c(1:2),8,replace=T)
guc<-function(x,y,z){length(u
On Sep 8, 2011, at 8:21 PM, Adam Pridgen wrote:
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
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
3 matches
Mail list logo