On Tue, 5 Oct 2004, Booker, Andrew J wrote:

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

Yes. R allows partial matching in this and many other contexts. You could use
"x1" %in% names(temd)
to test for the name without partial matching (probably more efficiently if the data frame is large)


        -thomas

______________________________________________
[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