An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130219/b7803f12/attachment.pl>
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:
Hi , I am trying to convert the date as factor to date using "as.date" function in R. I have the date in the following format 2008-01-01 02:30 I tried to use the following command : as.Date(mydata$Date, format="%y-%m-%d ") Can somebody help me with this ? I was able to convert the format with no hour but getting difficulty with hour included.
as.Date is about dates, but not hours. See ?strptime for a way to convert to POSIXlt / POSIXct representations. Best, Uwe Ligges
Thank you. Janesh [[alternative HTML version deleted]]
______________________________________________ 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.
jdbaba wrote
Hi , I am trying to convert the date as factor to date using "as.date" function in R. I have the date in the following format 2008-01-01 02:30 I tried to use the following command : as.Date(mydata$Date, format="%y-%m-%d ") Can somebody help me with this ? I was able to convert the format with no hour but getting difficulty with hour included. Thank you. Janesh [[alternative HTML version deleted]]
______________________________________________
R-help@
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.
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:
Hi , I am trying to convert the date as factor to date using "as.date" function in R. I have the date in the following format 2008-01-01 02:30 I tried to use the following command : as.Date(mydata$Date, format="%y-%m-%d ") Can somebody help me with this ? I was able to convert the format with no hour but getting difficulty with hour included. Thank you. Janesh [[alternative HTML version deleted]]
______________________________________________ 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.
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:
Hi , I am trying to convert the date as factor to date using "as.date" function in R. I have the date in the following format 2008-01-01 02:30 I tried to use the following command : as.Date(mydata$Date, format="%y-%m-%d ") Can somebody help me with this ? I was able to convert the format with no hour but getting difficulty with hour included. Thank you. Janesh [[alternative HTML version deleted]]
______________________________________________ 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.
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
-----Original Message----- From: janesh.devkota at gmail.com Sent: Tue, 19 Feb 2013 11:47:04 -0600 To: r-help at r-project.org Subject: [R] Converting the data in year month day hour and minutes to date Hi , I am trying to convert the date as factor to date using "as.date" function in R. I have the date in the following format 2008-01-01 02:30 I tried to use the following command : as.Date(mydata$Date, format="%y-%m-%d ") Can somebody help me with this ? I was able to convert the format with no hour but getting difficulty with hour included. Thank you. Janesh [[alternative HTML version deleted]]
______________________________________________ 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.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!