the date were created with chron with this argument format=c(dates="Y/m/d", times="H:M:S")) so I have the dates being displayed as (10/06/22 12:00:00) I would like to have them displayed as "2010-06-22 12:00:00" or "%Y-%m-%d %H:%M:%S" and then I can convert these for mergeing with another data frame x <- (structure(c(14464, 14464.0104166667, 14464.0208333333, 14464.03125, 14464.0416666667), format = structure(c("Y/m/d", "H:M:S"), .Names = c("dates", "times")), origin = c(1, 1, 1970), class = c("chron", "dates", "times"))) reading through old posts I found this: format(x, enclosed = c("", "")) which put the which surrounds the date time with "" instead of () now I would like to change the format of the dates to print like the above specified. kindest regards, -- Stephen Sefick ____________________________________ | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___________________________________| | sas0025 at auburn.edu | | http://www.auburn.edu/~sas0025 | |___________________________________| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
Stephen -> format(as.POSIXct(x),"%Y-%m-%d %H:%M:%S")[1] "2009-08-07 17:00:00" "2009-08-07 17:15:00" "2009-08-07 17:29:59" [4] "2009-08-07 17:45:00" "2009-08-07 18:00:00" - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spector at stat.berkeley.edu On Tue, 29 Jun 2010, stephen sefick wrote:> the date were created with chron with this argument > > format=c(dates="Y/m/d", times="H:M:S")) > > so I have the dates being displayed as > > (10/06/22 12:00:00) > > I would like to have them displayed as > > "2010-06-22 12:00:00" or "%Y-%m-%d %H:%M:%S" > > and then I can convert these for mergeing with another data frame > > x <- (structure(c(14464, 14464.0104166667, 14464.0208333333, 14464.03125, > 14464.0416666667), format = structure(c("Y/m/d", "H:M:S"), .Names = c("dates", > "times")), origin = c(1, 1, 1970), class = c("chron", "dates", > "times"))) > > reading through old posts I found this: > > format(x, enclosed = c("", "")) > > which put the which surrounds the date time with "" instead of () > now I would like to change the format of the dates to print like the > above specified. > kindest regards, > > -- > Stephen Sefick > ____________________________________ > | Auburn University | > | Department of Biological Sciences | > | 331 Funchess Hall | > | Auburn, Alabama | > | 36849 | > |___________________________________| > | sas0025 at auburn.edu | > | http://www.auburn.edu/~sas0025 | > |___________________________________| > > Let's not spend our time and resources thinking about things that are > so little or so large that all they really do for us is puff us up and > make us feel like gods. We are mammals, and have not exhausted the > annoying little problems of being mammals. > > -K. Mullis > > ______________________________________________ > 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. >
On Tue, Jun 29, 2010 at 2:01 PM, stephen sefick <ssefick at gmail.com> wrote:> the date were created with chron with this argument > > format=c(dates="Y/m/d", times="H:M:S")) > > so I have the dates being displayed as > > (10/06/22 12:00:00) > > I would like to have them displayed as > > "2010-06-22 12:00:00" or "%Y-%m-%d %H:%M:%S" > > and then I can convert these for mergeing with another data frame > > x <- (structure(c(14464, 14464.0104166667, 14464.0208333333, 14464.03125, > 14464.0416666667), format = structure(c("Y/m/d", "H:M:S"), .Names = c("dates", > "times")), origin = c(1, 1, 1970), class = c("chron", "dates", > "times"))) > > reading through old posts I found this: > > format(x, enclosed = c("", "")) > > which put the which surrounds the date time with "" instead of () > now I would like to change the format of the dates to print like the > above specified. > kindest regards, >Try this:> format(as.POSIXlt(x, tz = "GMT"))[1] "2009-08-08 00:00:00" "2009-08-08 00:15:00" "2009-08-08 00:29:59" [4] "2009-08-08 00:45:00" "2009-08-08 01:00:00"
On Tue, Jun 29, 2010 at 2:22 PM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> On Tue, Jun 29, 2010 at 2:01 PM, stephen sefick <ssefick at gmail.com> wrote: >> the date were created with chron with this argument >> >> format=c(dates="Y/m/d", times="H:M:S")) >> >> so I have the dates being displayed as >> >> (10/06/22 12:00:00) >> >> I would like to have them displayed as >> >> "2010-06-22 12:00:00" or "%Y-%m-%d %H:%M:%S" >> >> and then I can convert these for mergeing with another data frame >> >> x <- (structure(c(14464, 14464.0104166667, 14464.0208333333, 14464.03125, >> 14464.0416666667), format = structure(c("Y/m/d", "H:M:S"), .Names = c("dates", >> "times")), origin = c(1, 1, 1970), class = c("chron", "dates", >> "times"))) >> >> reading through old posts I found this: >> >> format(x, enclosed = c("", "")) >> >> which put the which surrounds the date time with "" instead of () >> now I would like to change the format of the dates to print like the >> above specified. >> kindest regards, >> > > Try this: > >> format(as.POSIXlt(x, tz = "GMT")) > [1] "2009-08-08 00:00:00" "2009-08-08 00:15:00" "2009-08-08 00:29:59" > [4] "2009-08-08 00:45:00" "2009-08-08 01:00:00" >Also here is another solution:> paste(as.Date(x), format(x - floor(x)))[1] "2009-08-08 00:00:00" "2009-08-08 00:15:00" "2009-08-08 00:30:00" [4] "2009-08-08 00:45:00" "2009-08-08 01:00:00"
Apparently Analagous Threads
- Chron format question h:m not working
- Zoo series to a date time stamp that is regular
- qplot in ggplot2 not working any longer - (what did I do?)
- loess line predicting number where the line crosses zero twice
- 4th corner analysis ade4 - what do the colors mean