[R] Sort of data.frame yields a thing which is not a data.frame...
Allen S. Rout
asr at ufl.edu
Tue Jun 20 21:52:36 CEST 2006
I've observed something I don't understand, and I was hoping someone
could point me to the right section of docs.
There's a portion in one of my analyses in which I am wont to sort a
data.frame so:
seriesS <- seriesS[order(as.Date(row.names(seriesS),format="%m/%d/%Y")),]
So, I've got row.names which are textual representations of dates, I'd
like to retain them as such, but order them datewise.
As long as seriesS has more than one column, this works nicely,
seriesS afterwards is a data.frame with columns similar to those it
had going in. But if I encounter a case with only one column, the
result is _not_ a data frame, but instead an ? array? list?
I can solve this with a kluge:
seriesS$stupid <- 0;
seriesS <- seriesS[order(as.Date(row.names(seriesS),format="%m/%d/%Y")),]
seriesS <- seriesS[,-c(which(names(seriesS)=="stupid")) ]
but this mostly tells me I've failed to understand something about how
the process should work.
Any good references to the Chapter and Verse of the Canon of R I
should hit?
- Allen S. Rout
More information about the R-help
mailing list