[R] NA rownames in dataframes

Yi, Derek Derek.Yi at FMR.COM
Wed Aug 28 20:57:36 CEST 2002


Hey everyone!

I am seeing strange behavior with NA in the rownames of dataframes:

> a <- data.frame(1:3, row.names = c("r1", NA, "r3"))
> cbind(a)
       X1.3
r1        1
<NA>      2
r3        3

Everything works.  The peculiar thing is that when the NA is in the first
row, things no longer work as I would have expected:

> b <- data.frame(1:3, row.names = c(NA, "r2", "r3"))
> cbind(b)
Error in if (missing(row.names) && (nrows[i] > 0) && (rowsi[[1]] != ""))
row.names <- data.row.names(row.names,  : 
	missing value where logical needed
> data.frame(b)
Error in if (missing(row.names) && (nrows[i] > 0) && (rowsi[[1]] != ""))
row.names <- data.row.names(row.names,  : 
	missing value where logical needed

> traceback()
3: data.frame(..., check.names = FALSE)
2: cbind(...)
1: cbind(b)

This seems to be a problem associated only with dataframes, as a similar
example using matrices works perfectly fine.  Has anyone experienced this
behavior before?

Thanks!

Derek

> R.version
         _                   
platform sparc-sun-solaris2.6
arch     sparc               
os       solaris2.6          
system   sparc, solaris2.6   
status                       
major    1                   
minor    5.1                 
year     2002                
month    06                  
day      17                  
language R
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list