> 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,
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
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
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
4 matches
Mail list logo