Re: [R] Help with dates

2017-12-29 Thread peter dalgaard
Mostly agree, except that I would suggest hardcoding the notion of "in the future", so that you don't get surprises when someone reruns your code 20 years from now. -pd > On 28 Dec 2017, at 21:54 , Simmering, Jacob E > wrote: > > Your dates have an incomplete year information with 34. R assu

Re: [R] Help with dates

2017-12-28 Thread Marc Girondot via R-help
Le 28/12/2017 à 18:13, Ramesh YAPALPARVI a écrit : Hi all, I’m struggling to get the dates in proper format. I have dates as factors and is in the form 02/27/34( 34 means 1934). If I use Try this x <- "02/27/34" x2 <- paste0(substr(x, 1, 6), "19", substr(x, 7, 8)) as.Date(x2, format="%m/%d/%Y

Re: [R] Help with dates

2017-12-28 Thread Simmering, Jacob E
Your dates have an incomplete year information with 34. R assumes that 00-68 are 2000 to 2068 and 69 to 99 are 1969 to 1999. See ?strptime and the details for %y. You can either append “19” to the start of your year variable to make it completely express the year or check if the date is in the

Re: [R] Help with dates and characters

2010-06-29 Thread Allan Engelhardt
If the vector elements are (still) strings, you could simply try x<- c("2000-01-01", "2000-01-23", "2001-03-12", "2009-12-31") substring(x, 1, 7) # [1] "2000-01" "2000-01" "2001-03" "2009-12" Hope this helps a little. Allan On 29/06/10 14:36, Thomas Jensen wrote: Dear R Experts, I have a

Re: [R] Help with dates and characters

2010-06-29 Thread Marc Schwartz
On Jun 29, 2010, at 8:36 AM, Thomas Jensen wrote: > Dear R Experts, > > I have a vector of dates in character format like this: > > date > "2000-01-01" > "2000-01-23" > "2001-03-12" > ... > ... > ... > "2009-12-31" > > I would like to delete the last part of the character string (i.e. the "day"