An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130423/c4e6df11/attachment.pl>
Time and Date formatting
5 messages · Rui Barradas, Ayyappa Chaturvedula, Jeff Newmiller
Hello, See if any of the following will do. DATE <- "14/07/2010" TIME <- "20:21" paste(DATE, TIME) as.POSIXct(paste(DATE, TIME), format = "%d/%m/%Y %H:%M") Hope this helps, Rui Barradas Em 23-04-2013 19:46, Ayyappa Chaturvedula escreveu:
Dear Group, I have a problem with time date formatting. I have Date and Time in different columns in a .csv file and want to have a column with Date and Time together. I could format the date into the right mode using strptime and as.Date functions. I am not able to do that with TIME column. I appreciate your help in solving this issue. Currently the TIME column is in character mode. DATE TIME DATETIME 14/07/2010 20:21 *Want:* 14/07/2010 20:11 Thanks in advance for your help. Regards, Ayyappa [[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.
Hello, Forgot to add strptime, like you had noted. strptime(paste(DATE, TIME), format = "%d/%m/%Y %H:%M") Rui Barradas Em 23-04-2013 19:54, Rui Barradas escreveu:
Hello, See if any of the following will do. DATE <- "14/07/2010" TIME <- "20:21" paste(DATE, TIME) as.POSIXct(paste(DATE, TIME), format = "%d/%m/%Y %H:%M") Hope this helps, Rui Barradas Em 23-04-2013 19:46, Ayyappa Chaturvedula escreveu:
Dear Group,
I have a problem with time date formatting. I have Date and Time in
different columns in a .csv file and want to have a column with Date and
Time together. I could format the date into the right mode using
strptime
and as.Date functions. I am not able to do that with TIME column. I
appreciate your help in solving this issue. Currently the TIME column is
in character mode.
DATE TIME DATETIME
14/07/2010 20:21 *Want:* 14/07/2010 20:11
Thanks in advance for your help.
Regards,
Ayyappa
[[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.
______________________________________________ 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.
That works for me and thanks for the help.
On Apr 23, 2013, at 2:59 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
Hello, Forgot to add strptime, like you had noted. strptime(paste(DATE, TIME), format = "%d/%m/%Y %H:%M") Rui Barradas Em 23-04-2013 19:54, Rui Barradas escreveu:
Hello, See if any of the following will do. DATE <- "14/07/2010" TIME <- "20:21" paste(DATE, TIME) as.POSIXct(paste(DATE, TIME), format = "%d/%m/%Y %H:%M") Hope this helps, Rui Barradas Em 23-04-2013 19:46, Ayyappa Chaturvedula escreveu:
Dear Group, I have a problem with time date formatting. I have Date and Time in different columns in a .csv file and want to have a column with Date and Time together. I could format the date into the right mode using strptime and as.Date functions. I am not able to do that with TIME column. I appreciate your help in solving this issue. Currently the TIME column is in character mode. DATE TIME DATETIME 14/07/2010 20:21 *Want:* 14/07/2010 20:11 Thanks in advance for your help. Regards, Ayyappa [[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.
______________________________________________ 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.
a) In some analyses, date/time values are only needed to identify data records, in which case a simple paste is enough.
b) If you ARE going to need to to calculate or plot date/time and choose to use POSIXt types to represent it, make a habit of always setting your "local" (local to the computer process, at least) timezone to match the timezone of your data (e.g. Sys.setenv( TZ="Etc/GMT+8")) at least for the duration of this conversion to avoid mysterious NA values in the POSIX data. If you don't want to be bothered with time zones, then use the chron library as mentioned in ?as.POSIXct.
---------------------------------------------------------------------------
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.
Rui Barradas <ruipbarradas at sapo.pt> wrote:
Hello, Forgot to add strptime, like you had noted. strptime(paste(DATE, TIME), format = "%d/%m/%Y %H:%M") Rui Barradas Em 23-04-2013 19:54, Rui Barradas escreveu:
Hello, See if any of the following will do. DATE <- "14/07/2010" TIME <- "20:21" paste(DATE, TIME) as.POSIXct(paste(DATE, TIME), format = "%d/%m/%Y %H:%M") Hope this helps, Rui Barradas Em 23-04-2013 19:46, Ayyappa Chaturvedula escreveu:
Dear Group, I have a problem with time date formatting. I have Date and Time
in
different columns in a .csv file and want to have a column with Date
and
Time together. I could format the date into the right mode using strptime and as.Date functions. I am not able to do that with TIME column. I appreciate your help in solving this issue. Currently the TIME
column is
in character mode.
DATE TIME DATETIME
14/07/2010 20:21 *Want:* 14/07/2010 20:11
Thanks in advance for your help.
Regards,
Ayyappa
[[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.
______________________________________________ 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.
______________________________________________ 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.