This is probably a know problem (problem for me anyway) in R but I
don't quite know what to search for in help archives. When I name a
column "x11" in a data frame R thinks a column named "x1" exists. In
my application I am trying to test for the existence of a column, then
add it if it's not there. Here is a simple example:

> temd <- data.frame(x11=c(0:10))
> is.null(temd[["x1"]])
[1] FALSE
> temd[["x1"]]
 [1]  0  1  2  3  4  5  6  7  8  9 10
> temd$x1
 [1]  0  1  2  3  4  5  6  7  8  9 10
> temd[,"x1"]
Error in "[.data.frame"(temd, , "x1") : undefined columns selected
>

This is in R 2.0.0.

Anyone know how to run (safely) through a list of names like "x1"-"x100" and check for 
data frame columns with the names?



----------------------------------------------------------- 
* Opinions herein are mine only *
----------------------------------------------------------- 

                        Andrew Booker   
                        The Boeing Company
                        P.O. Box 3707 MC 7L-22
                        Seattle, WA  98124-2207
                        425-865-3573
                        FAX# 425-865-2966
                        [EMAIL PROTECTED]

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to