[R] Graphing a subset of data

S Ellison S.Ellison at LGCGroup.com
Tue Dec 1 15:00:52 CET 2015


> graphit<-function(x,var,type,subset=NA,...){
>  if(!is.na(subset[1])) x<-subset(x,subset)
>  do.call(type,list(x=x[[var]],...))
> }

A further slight simplification is possible using the fact that subset(x, TRUE) returns x unchanged:

graphit<-function(x,var,type,subset=TRUE,...){
  x<-subset(x,subset)
  do.call(type,list(x=x[[var]],...))
}

S Ellison


*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list