Displaying 1 result from an estimated 1 matches for "demo_char".
2011 Nov 07
2
Problem working with dates
...39;
How can I correct this problem before calculating age in the code below?
DOB starts out as a factor in the Demo dataframe but then is converted into a date. So I had thought the ifelse that follows could be used to correct the problem, but this doesn't seem to be the case.
Thanks,
Paul
Demo_Char <- within(Demo, {
DateCompleted <- as.Date(DateCompleted, format = "%m/%d/%Y")
DOB <- as.Date(DOB, format = "%m/%d/%Y")
DOB <- ifelse(Subject==108945, as.Date("1931-11-23"), DOB)
Age <- as.integer((DateCompleted - DOB) / 365.25)
})