[R] about "undefined columns selected"

Milan Bouchet-Valat nalimilan at club.fr
Mon Jan 30 09:48:30 CET 2012


Le dimanche 29 janvier 2012 à 21:50 -0500, xiaocong zuo a écrit :
> Hi,all,
> 
> when I run the below code,there is an error occured. could you please tell
> me how to treat it?
> > pdf('covariate.pdf')
> > par(mfrow=c(1,1))
> > pairs(data2[,c("ID","TYPE","AGE","GNDR","HT")],
> + panel=function(x,y) { points(x,y); lines(lowess(x,y))})
> Error in `[.data.frame`(data2, , c("ID", "TYPE", "AGE", "GNDR", "HT")) :
> undefined columns selected
> > dev.off()
> RStudioGD
> 2
> Thank you very much!
This simply means that one of the columns you tried to select doesn't
exist in data2. You can see what columns are present using:
colnames(data2)

or since data2 is a data frame:
names(data2)


But you could probably have figured this out by yourself... ;-)

Hope this helps



More information about the R-help mailing list