Hi Alexandra, I think you are going about this in an excessively difficult way. Here is a rough example:
graphit<-function(x,var,type,subset=NA,...){ if(!is.na(subset[1])) x<-subset(x,subset) do.call(type,list(x=x[[var]],...)) } # assume that the data are measurements of penetration by crossbow bolts at specified speeds bolts<-data.frame(SPEED1=rep(1:3,each=30), penetration=c(runif(30,10,15),runif(30,15,20),runif(30,20,25))) # note the lazy way of adding arguments to the function call graphit(bolts,"SPEED1",boxplot,main="Boxplot of SPEED1") graphit(bolts,"penetration",boxplot,subset=bolts$SPEED1==3, main="Boxplot of SPEED1 == 3") graphit(bolts,"SPEED1",hist,main="Histogram of SPEED1") Jim [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.