[R] Datetime conversion

premmad mtechprem at gmail.com
Fri Sep 18 13:32:27 CEST 2009


Sorry for confusing you all with my inexperienced posting .
I tried as u said if you have 9 rows in the data it is working fine but
please try out the same example as you have suggested earlier with morethan
9 rows.

I tried it as following
datetime <-c(
+ "01OCT1987:00:00:00.000",
+  "12APR2004:00:00:00.000",
+   "01DEC1987:00:00:00.000",
+  "01OCT1975:00:00:00.000",
+   "01AUG1979:00:00:00.000",
+  "26JUN2003:00:00:00.000",
+  "01JAN1900:00:00:00.000",
+  "13MAY1998:00:00:00.000",
+  "30SEP1998:00:00:00.000",
+  "30SEP1998:00:00:00.000",
+  "30SEP1998:00:00:00.000",
+  "30SEP1998:00:00:00.000") 
dt <- as.data.frame(datetime) 

dt$date<-strptime(as.character(dt$datetime),"%d%b%Y") 

and got the following error :

Error in `$<-.data.frame`(`*tmp*`, "date", value = list(sec = c(0, 0,  : 
  replacement has 9 rows, data has 12.


MY session info details are as follows:

R version 2.9.2 (2009-08-24) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] tcltk     stats     graphics  grDevices utils     datasets  methods  
base     

other attached packages:
[1] sqldf_0-1.5     gsubfn_0.5-0    proto_0.3-8     RSQLite_0.7-2  
DBI_0.2-4       lattice_0.17-25 chron_2.3-30   

loaded via a namespace (and not attached):
[1] grid_2.9.2  tools_2.9.2
-- 
View this message in context: http://www.nabble.com/Datetime-conversion-tp25503138p25507205.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list