Skip to content
Prev 59489 / 63430 Next

Corrupt internal row names when creating a data.frame with `attributes<-`

as.matrix.data.frame does not take the absolute value of that number:
  > dPos <- structure(list(X=101:103,201:203),class="data.frame",row.names=c(NA_integer_,+3L))
  > dNeg <- structure(list(X=101:103,201:203),class="data.frame",row.names=c(NA_integer_,-3L))
  > rownames(as.matrix(dPos))
  [1] "1" "2" "3"
  > rownames(as.matrix(dNeg))
  NULL

-Bill
On Tue, Feb 16, 2021 at 11:06 AM Kevin Ushey <kevinushey at gmail.com> wrote: