Hi ,
I have a huge data set (192840 x 5) and would like to convert the date and
time format.
The data looks something like below :
0 03/01/1983 01:00 -0.10 359.0
0 03/01/1983 02:00 -0.10 359.0
0 03/01/1983 03:00 -0.10 359.0
0 03/01/1983 04:00 -0.10 359.0
0 03/01/1983 05:00 -0.10 359.0
0 03/01/1983 06:00 -0.10 359.0
0 03/01/1983 07:00 -0.10 359.0
I will like to change the date format to 1983-01-03 and the time format to
01:00:00.
I have used the following code :
sample <- read.table("321.txt",header=F)
Date = sample[,2]
Time = sample[,3]
timedf <- data.frame(Date, Time)
strptime( with(timedf, paste(Date,Time) ), format="%d/%m/%y %H:%M")
The code works when I define Date and Time individually*, but when I try to
run it with all the data in the datasets the solution that comes out is
"NA".
Is there a way around this?
Your help is very much appreciated
*E.g
timedf <- data.frame(Date1 = "20/12/08", Time1= "17:00")
> strptime( with(timedf, paste(Date1,Time1) ), format="%d/%m/%y %H:%M")
[] 2008-12-20 17:00:00
--
View this message in context:
http://r.789695.n4.nabble.com/Date-and-Time-Formatting-tp2310015p2310015.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
[email protected] 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.