Dear all! I have a new problem with the date format in a data frame. I have rainfall records extracted from an automatic meteo station. In the same data frame (with 10000 records) the date is in 2 formats like that: 4/15/11 11:49 AM 5.6.11 2:51 PM My question is how to modify date format for all records with this format type: 4/15/11 11:49 AM. Thank you! Best regards! Catalin -- --- Catalin-Constantin ROIBU Lecturer PhD, Forestry engineer Forestry Faculty of Suceava Str. Universitatii no. 13, Suceava, 720229, Romania office phone +4 0230 52 29 78, ext. 531 mobile phone +4 0745 53 18 01 +4 0766 71 76 58 FAX: +4 0230 52 16 64 silvic.usv.ro [[alternative HTML version deleted]]
Try: vec1 <- c("4/15/11 11:49 AM", "6/12/12 2:30 PM", "5.6.11 2:51 PM") vec2 <- gsub("[.]","/",vec1) A.K. On Thursday, March 13, 2014 9:57 AM, catalin roibu <catalinroibu at gmail.com> wrote: Dear all! I have a new problem with the date format in a data frame. I have rainfall records extracted from an automatic meteo station. In the same data frame (with 10000 records) the date is in 2 formats like that: 4/15/11 11:49 AM 5.6.11 2:51 PM My question is how to modify date format for all records with this format type: 4/15/11 11:49 AM. Thank you! Best regards! Catalin -- --- Catalin-Constantin ROIBU Lecturer PhD, Forestry engineer Forestry Faculty of Suceava Str. Universitatii no. 13, Suceava, 720229, Romania office phone? ? +4 0230 52 29 78, ext. 531 mobile phone? +4 0745 53 18 01 ? ? ? ? ? ? ? ? ? ? ? +4 0766 71 76 58 FAX:? ? ? ? ? ? ? ? +4 0230 52 16 64 silvic.usv.ro ??? [[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.
I would use gsub() to change instances like 5.6.11 to 5/6/11. Hopefully, both versions have month and day in the same order. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 3/13/14 6:57 AM, "catalin roibu" <catalinroibu at gmail.com> wrote:>Dear all! > >I have a new problem with the date format in a data frame. I have rainfall >records extracted from an automatic meteo station. In the same data frame >(with 10000 records) the date is in 2 formats like that: >4/15/11 11:49 AM >5.6.11 2:51 PM > >My question is how to modify date format for all records with this format >type: 4/15/11 11:49 AM. > >Thank you! >Best regards! > >Catalin > >-- >--- >Catalin-Constantin ROIBU >Lecturer PhD, Forestry engineer >Forestry Faculty of Suceava >Str. Universitatii no. 13, Suceava, 720229, Romania >office phone +4 0230 52 29 78, ext. 531 >mobile phone +4 0745 53 18 01 > +4 0766 71 76 58 >FAX: +4 0230 52 16 64 >silvic.usv.ro > > [[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.