[R] difftime in years
wdunlap at tibco.com
Thu Aug 4 22:35:16 CEST 2016
difftime objects do not accept 'years' as a value for 'units', so you have
to change it to numeric.
as.numeric(age_days, units="days") / 365.242
The units="days" is not needed since you specified it in the call
to difftime, but it needs to be in one of those places.
On Thu, Aug 4, 2016 at 11:05 AM, Thomas Subia via R-help <
r-help at r-project.org> wrote:
> age_days <- difftime(Date,DOM,units="days")
> date_vals$age_yrs <- age_days/365.242
> I'm trying to calculate the number of years between DOM and Date.
> The output reads
> DOM Date age_yrs
> 1 2005-04-04 2015-05-13 10.10563 days
> How does one not output days?
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help