[R] row.names c(NA, -length) vs. c(NA, +length)

William Dunlap wdunlap at tibco.com
Sat Jun 18 01:39:20 CEST 2016


The default row.names on a data.frame made by the core-R data.frame
function are of the the form c(NA, -NROW(dataFrame)).  The dplyr package
has a 'data_frame' function that uses c(NA, +NROW(dataFrame)) instead.  The
tibble package also has a data_frame function, but it uses the negative
length.

As far as I can see, the positive and negative forms mean the same thing.
Is there any reason for the difference?  It makes testing a bit difficult
since all.equal() says they are the the same but identical() says they
differ.

> base::.row_names_info(dplyr::data_frame(X=101:110), 0)
[1] NA 10
> base::.row_names_info(tibble::data_frame(X=101:110), 0)
[1]  NA -10
> base::.row_names_info(base::data.frame(X=101:110), 0)
[1]  NA -10
>
> packageDescription("dplyr")$Author
[1] "Hadley Wickham [aut, cre],\n  Romain Francois [aut],\n  RStudio [cph]"
> packageDescription("tibble")$Author
[1] "Hadley Wickham [aut],\n  Romain Francois [aut],\n  Kirill Müller [aut,
cre],\n  RStudio [cph]"
> packageDescription("base")$Author
[1] "R Core Team and contributors worldwide"


Bill Dunlap
TIBCO Software
wdunlap tibco.com

	[[alternative HTML version deleted]]



More information about the R-help mailing list