[R] rbind/timestamp problem
jim holtman
jholtman at gmail.com
Tue Dec 10 15:40:08 CET 2013
try this:
> sensitivity=rbind(sensitivity,data.frame(mtype=2,cdate=as.POSIXct(Sys.time(), origin="1970-01-01")))
> sensitivity
mtype cdate
1 1 2013-12-10 09:35:53
2 2 2013-12-10 09:37:02
The 'c' function is coercing to numeric. If you want to 'rbind' rows
to a dataframe, then make sure you use a dataframe.
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Tue, Dec 10, 2013 at 8:55 AM, Georg Hörmann
<ghoermann at hydrology.uni-kiel.de> wrote:
> Hello world,
>
> I am stuck somehow...
> I am trying to add a timestamp to a sensitivity matrix:
>
> #this code works:
>
> sensitivity=data.frame(mtype=1,cdate=2)
> sensitivity=rbind(sensitivity,c(mtype=2,cdate=2))
>
> # this code does not work - no idea why
>
> sensitivity=data.frame(mtype=1,cdate=as.POSIXct(Sys.time(),
> origin="1970-01-01"))
> sensitivity=rbind(sensitivity,c(mtype=2,cdate=as.POSIXct(Sys.time(),
> origin="1970-01-01")))
>
> Error message:
> "Error in as.POSIXct.numeric(value) : 'origin' must be supplied"
>
> Any hints why the second part does not work?
>
> Greetings,
> Georg
>
> --
> Georg Hoermann, Dep. of Hydrology, Ecology, Kiel University, Germany
> +49/431/2190916, mo: +49/176/64335754, icq:348340729, skype: ghoermann
>
> ______________________________________________
> 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