Hello list! Let's construct a matrix / data.frame with 0 columns, but > 0 rows, and non-NULL rownames. Then, call is.na() on both the data.frame and the matrix. We find that is.na.data.frame() gives an error. When row.names are removed, is.na.data.frame() returns NULL. I think that the NULL result is also wrong. From ?is.na:
The method ‘is.na.data.frame’ returns a logical matrix with the same dimensions as the data frame, and with dimnames taken from the row and column names of the data frame. No problems are seen when is.na() is run on the matrix. What do you think, should a formal bug report be filed? > options(width=60) > foo.mat <- matrix(nrow=26, ncol=0, dimnames=list(letters)) > foo.df <- as.data.frame(foo.mat) > foo.df data frame with 0 columns and 26 rows > row.names(foo.df) [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" [15] "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" > is.na(foo.df) Error in `rownames<-`(`*tmp*`, value = row.names(x)) : attempt to set rownames on object with no dimensions > traceback() 4: stop("attempt to set rownames on object with no dimensions") 3: `rownames<-`(`*tmp*`, value = row.names(x)) 2: is.na.data.frame(foo.df) 1: is.na(foo.df) > row.names(foo.df) <- NULL > is.na(foo.df) NULL > is.na(foo.mat) a b c ## ... rows removed > sessionInfo() R Under development (unstable) (2012-06-19 r59583) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8 [5] LC_MONETARY=en_US.utf8 LC_MESSAGES=en_US.utf8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets [6] methods base loaded via a namespace (and not attached): [1] tools_2.16.0 -- Mikko Korpela Aalto University School of Science Department of Information and Computer Science ______________________________________________ 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.