I am trying to create a heap of boxplots, by looping though a series of
factors and variables in a large data.frame suing paste to constrcut the
facto and response names from the colnames
I thought I could do this using get()
however it is not working what am I doing wrong?
thanks
Nevil Amos
sp.codes=levels(data.all$CODE_LETTERS)
for(spp in sp.codes) {
data.sp=subset(data.all,CODE_LETTERS==spp)
responses = colnames(data.all)[c(20,28,29,19)]
#if (spp=="BT") responses = colnames(data.all)[c(19,20,26:29)]
groups=colnames (data.all)[c(9,10,13,16,30)]
data.sp=subset(data.all,CODE_LETTERS==spp)
for (response in responses){
for (group in groups){
r<-get(paste("data.sp$",response,sep=""))
g<-get(paste("data.sp$",group, sep=""))
print (r)
print(g)
boxplot(r ~g)
}}}
Error in get(paste("data.sp$", response, sep = "")) :
object 'data.sp$Hb' not found
______________________________________________
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.