Skip to content

unlist() list of dates

3 messages · William Dunlap, Ana

Ana
#
how can I keep the date info after doing unlist to a list of dates?

I have a list of dates were observations were made for each station in
each month

list.obs[[station]][month]

[1] "1979-01-01" "1979-01-10" "1979-01-25"

[1]     0     1     2     3

when i try to unlist i loose the date info.

what am I doing wrong?
#
There are methods of the "c" function for things of class "POSIXlt" and "Date"
so do.call("c", dataList) works instead of unlist:
  > dateList <- list(LastWeekend=as.POSIXlt(sprintf("2011-12-%d", 10:11)),
  +                  Today=as.POSIXlt("2011-12-12"))
  > z <- do.call("c", dateList)
  > z
      LastWeekend1     LastWeekend2            Today
  "2011-12-10 PST" "2011-12-11 PST" "2011-12-12 PST"
  > str(z)
   POSIXlt[1:3], format: "2011-12-10" "2011-12-11" "2011-12-12"
   - attr(*, "names")="LastWeekend1" "LastWeekend2" "Today"

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
Ana
#
Thanks!

Another question also related to the same type of files:

How can I transform it into a time series
as.ts()

I also endup having the same problem, the dates are transformed into a
list of numbers

My file looks like this
          dates        val
1    2001-01-12    1.2
2    2001-02-12    1.2
2    2001-03-12    1.2

(...)

class: data.frame
On Mon, Dec 12, 2011 at 6:30 PM, William Dunlap <wdunlap at tibco.com> wrote: