Quite simply I want to calculate tenure, if an employee is termed, then I want the new field to return Term. Date - Job.Entry.Date to calculate tenure. Otherwise, if the employee is active, then I want the new field to return Sys.Date - Job.Entry.Date.
With the following Code:
jobentrydat_alltechs$Tenure <-if (jobentrydat_alltechs$Term.Date == is.na) {
return (difftime(Sys.Date(), jobentrydat_alltechs$Job.Entry.Date, units = c("days")))
} else if (jobentrydat_alltechs$Term.Date != is.na) {
return (difftime(jobentrydat_alltechs$Term.Date, jobentrydat_alltechs$Job.Entry.Date, units = c("days")))
}
I am getting the following error
Error in
==.default
(jobentrydat_alltechs$Term.Date, is.na) :
comparison (1) is possible only for atomic and list types