MIchael -
Thanks for your insight. I think I see where you're going with this.
To make '==' comparisons for subsetting against an ordered factor, I've had
to create a lookup table for all possible values I'd ever want to compare
against (all dates covered by the quarters in question, in this
This error occurs because the == comparison operator doesn't allow
comparison of ordered and normal factors:
/df[df5$close_quarter == as.Date(2011-02-01),]/
Warning message:
In /`[.data.frame`(df, df$close_quarter == as.Date(2011-02-01)/, :
Incompatible methods (Ops.ordered, Ops.Date) for ==
The short answer to your question is *don't* concatenate the values in the
row, then attempt to /rbind()/ them incrementally to a data.frame. Instead
build each column separately inside the loop, then /cbind() (data.frame()/
does an implicit/ cbind()/ ) them together at the end. Something like
What I want to do is create a data.frame column from ranges of dates (e.g.
annual quarters) as an ordered factor, then use this column to select by
ranges of the factor (e.g. all quarters in 2009).
The factors capture the date ranges, instead of having to write elaborate
code to do range
4 matches
Mail list logo