Rina Oldager Miehs wrote: > Hi > > My dataframe is imported from SAS as a csv file(which cant be any > different). > > There is a vector "dato" that is dates like this: > 03/12/2004 and that is *day/month/year*. > >> vms[1:20,] > CKRDYRNR RACE_ID datofra minkaelvedato CHRNR cowno > *dato* opstartdato > muno timestamp closingtime transtype > 1 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 03/12/2004 30APR2004 1 03DEC2004:18:54:48.0 > 03DEC2004:19:01:37.0 1 > 2 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 04/12/2004 30APR2004 1 04DEC2004:19:10:29.0 > 04DEC2004:19:15:41.0 1 > 3 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 05/12/2004 30APR2004 1 05DEC2004:18:37:37.0 > 05DEC2004:18:51:23.0 1 > 4 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 06/12/2004 30APR2004 1 06DEC2004:10:18:16.0 > 06DEC2004:10:24:50.0 1 > 5 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 07/12/2004 30APR2004 2 07DEC2004:19:51:52.0 > 07DEC2004:19:56:51.0 1 > 6 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 08/12/2004 30APR2004 1 08DEC2004:23:44:51.0 > 08DEC2004:23:55:21.0 1 > 7 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 09/12/2004 30APR2004 1 09DEC2004:22:01:46.0 > 09DEC2004:22:07:50.0 1 > 8 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 10/12/2004 30APR2004 2 10DEC2004:12:47:56.0 > 10DEC2004:12:59:24.0 1 > 9 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 11/12/2004 30APR2004 1 11DEC2004:23:16:38.0 > 11DEC2004:23:26:50.0 1 > 10 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 12/12/2004 30APR2004 2 12DEC2004:18:30:28.0 > 12DEC2004:18:36:42.0 1 > 11 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 13/12/2004 30APR2004 1 13DEC2004:23:00:28.0 > 13DEC2004:23:06:25.0 1 > 12 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 14/12/2004 30APR2004 1 14DEC2004:13:00:37.0 > 14DEC2004:13:05:29.0 1 > 13 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 15/12/2004 30APR2004 2 15DEC2004:20:01:36.0 > 15DEC2004:20:06:17.0 1 > 14 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 16/12/2004 30APR2004 2 16DEC2004:14:53:20.0 > 16DEC2004:14:59:49.0 1 > 15 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 17/12/2004 30APR2004 1 17DEC2004:15:31:20.0 > 17DEC2004:15:38:17.0 1 > 16 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 18/12/2004 30APR2004 1 18DEC2004:20:19:07.0 > 18DEC2004:20:25:05.0 1 > 17 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 19/12/2004 30APR2004 1 19DEC2004:18:33:58.0 > 19DEC2004:18:41:11.0 1 > 18 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 20/12/2004 30APR2004 1 20DEC2004:13:12:09.0 > 20DEC2004:13:18:16.0 1 > 19 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 21/12/2004 30APR2004 1 21DEC2004:15:05:20.0 > 21DEC2004:15:13:17.0 1 > 20 8004500307 1203 29OCT2004 03DEC2004 19365 307 > 22/12/2004 30APR2004 1 22DEC2004:14:36:19.0 > 22DEC2004:14:44:28.0 1 > > > It is read as a factor by R and I cant find a way to translate them to a > date class because the functions i can find and have used before on other > data is mdy.
In R? How? > Can anyone help me with this? as.Date( ..., format="%d/%m/%Y") should do it, I think. (Now, if you had previously done the same thing with "%m/%d/%Y" I'd be somewhat puzzled as to why you couldn't generalize it...) -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ R-help@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.