[R] colnames documentation
R. Michael Weylandt
michael.weylandt at gmail.com
Fri Feb 10 04:53:42 CET 2012
Consider the following in R 2.14.1 (seems to still be the case in Rdevel):
x <- matrix(1:9, 3)
colnames(x) # NULL as expected
colnames(x, do.NULL = TRUE) # NULL -- since we didn't change the default
colnames(x, do.NULL = FALSE) # "col1" "col2" "col3"
This doesn't really seem to square with the documentation which reads:
do.NULL: logical. Should this create names if they are ‘NULL’?
The details section expounds and says:
If ‘do.NULL’ is ‘FALSE’, a character vector (of length ‘NROW(x)’
or ‘NCOL(x)’) is returned in any case, prepending ‘prefix’ to
simple numbers, if there are no dimnames or the corresponding
component of the dimnames is ‘NULL’.
But I have to admit that I don't really get it. (The interpretation of
the docs; I understand the functionality) Could someone enlighten me?
Given what the details section says (and the behavior of the function
is), I'd expect something more like:
do.NULL: logical. Is NULL an acceptable return value? If FALSE,
column names derived from prefix are returned.
Michael
PS -- In my searching, I think the link to the svn on the developer
page (http://developer.r-project.org/) is wrong: clicking it takes one
to what appears to be the same page: am I incorrect in assuming it
should link to http://svn.r-project.org/R for the current svn?
More information about the R-help
mailing list