[R] Time problems (POSIXct)

Cedrick W. Johnson cedrick at cedrickjohnson.com
Thu May 20 16:56:41 CEST 2010


try:

as.POSIXct(datestr, format="%y-%m-%d")

for the first timeseries...

-c


On 5/20/2010 10:48 AM, Research wrote:
> Hello,
>
> I have a zoo time series object (say a) with the following time
> stamp/format
>
>
>
> [1] "1950-01-03 GMT" "1950-01-04 GMT" "1950-01-05 GMT" "1950-01-06 GMT"
> [5] "1950-01-09 GMT" "1950-01-10 GMT"
>
>
> and another (say b) with
>
>
> [1] "1950-01-05" "1950-01-06" "1950-01-09" "1950-01-10" "1950-01-11"
> [6] "1950-01-12"
>
>
> I want to merge these series but when I try:
>
>
>  > head(merge(a, b ))
> a b
> 1950-01-03 02:00:00 16.66 NA
> 1950-01-04 02:00:00 16.85 NA
> 1950-01-05 02:00:00 16.93 NA
> 1950-01-06 02:00:00 16.98 NA
> 1950-01-09 02:00:00 17.08 NA
> 1950-01-10 02:00:00 17.03 NA
> Warning message:
> In merge.zoo(a, b) :
> Index vectors are of different classes: POSIXt Date
>  >
>
> Anybody can help? I tried as.POSIXct(a,tz="GMT") but it doesn't seem to
> work....
>
> Many thanks in advance!
>
> Costas
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 10.1
> year 2009
> month 12
> day 14
> svn rev 50720
> language R
> version.string R version 2.10.1 (2009-12-14)
>  >
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list