Re: [R] Help with changing date format in R

2021-01-20 Thread Marc Schwartz via R-help
Hi, Internally, once you have a Date class object in R, the "printed" output displayed will be the default, which I believe is influenced by your locale. See ?format.Date. That being said, in your example data below, 07022020, could be either July 2, 2020, or February 7, 2020. How do you know

Re: [R] Help with changing date format in R

2021-01-20 Thread Jeff Newmiller
Perhaps d$date <- as.Date(d$date, format = ifelse("K"==d$observer, "%d%m%Y", "%m%d%Y" )) On January 20, 2021 8:08:33 AM PST, krissievdh wrote: >Hi, > >I have a big database where one-third of the data is in a different >date >format than the rest. I'll add an example table to show you. > >|

Re: [R] Help with changing date format in R

2021-01-20 Thread Sarah Goslee
Hi, If the date format is determined by observer, you could for instance use subset to divide it into two data frames, fix the dates and recombine, or use ifelse to use the correct format based on observer. This is a basic data manipulation task, and there are lots of ways approach it. Sarah On

[R] Help with changing date format in R

2021-01-20 Thread krissievdh
Hi, I have a big database where one-third of the data is in a different date format than the rest. I'll add an example table to show you. | plot | observer | date| | 1 | K | 31012020 | | 2 | K |