For example:

# dataset
age<-18:29
height<-58:69
df.ex=data.frame(age=age,height=height)
df.ex[4,1]<-NA

# dataset of columns that will be used for analysis
values<-c("age", "height")
df.variables=data.frame(values)

 # Age column has a null (NA) value.  The row must be removed for the
analysis to run
 # explicit creation  
df.ex.sub.explicit<-subset(df.ex, age >= 0)
dim(df.ex.sub.explicit) #11 obs of 2 variables

i=1
strFilter=as.character(df.variables$values[i])
df.ex.sub.passvar<-subset(df.ex,strFilter>=0)
dim(df.ex.sub.explicit) #12 obs of 2 variables


--
View this message in context: 
http://r.789695.n4.nabble.com/Create-subset-using-variable-tp4316812p4317196.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to