Re: [R] Graphing a subset of data

2015-12-01 Thread S Ellison
> 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,

Re: [R] Graphing a subset of data

2015-12-01 Thread Jim Lemon
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

Re: [R] Graphing a subset of data

2015-11-30 Thread David Winsemius
Dear Alex (as you are signing yourself on StackOverflow); It is considered poor manners to cross-post identical questions in multiple venues. http://stackoverflow.com/questions/34011669/graphing-function-based-on-subset-of-data You should choose one or the other of SO and Rhelp. If you do not

[R] Graphing a subset of data

2015-11-30 Thread Alexandra Hua
I am trying to write a function that will graph a variable of a dataset or a variable from a subset of the data. My function is as follows: graphics<-function(dat, var, graph, varname, val, subset){ if(subset==1) { data<-mySubset(dat=dat,varname=varname,val=val) }else if(subset!=1){ da