Skip to content

Converting the data in year month day hour and minutes to date

6 messages · Janesh Devkota, Uwe Ligges, Pete Brecknock +3 more

#
On 19.02.2013 18:47, Janesh Devkota wrote:
as.Date is about dates, but not hours. See ?strptime for a way to 
convert to POSIXlt / POSIXct representations.

Best,
Uwe Ligges
#
jdbaba wrote

            
how about 

as.POSIXlt("2008-01-01 02:30", format="%Y-%m-%d %H:%M") 

Pete



--
View this message in context: http://r.789695.n4.nabble.com/Converting-the-data-in-year-month-day-hour-and-minutes-to-date-tp4659075p4659080.html
Sent from the R help mailing list archive at Nabble.com.
#
Hello,

Try the following.


x <- "2008-01-01 02:30"
as.POSIXct(x, format = "%Y-%m-%d %H:%M")


Hope this helps,

Rui Barradas

Em 19-02-2013 17:47, Janesh Devkota escreveu:
#
It is possible to squeeze a square peg into a round hole, but often you will not be satisfied with the result. Date is for... surprise, dates. You may want to use the chron package or the POSIXct type. The R Journal of June 2004 (Volume 4/1) "R Help Desk" column is recommended reading.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Janesh Devkota <janesh.devkota at gmail.com> wrote:

            
#
You need to convert the factor to character.

as.Date( as.character(mydata$Date), "%Y-%m-%d")

should do it.
John Kane
Kingston ON Canada
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!