I'd appreciate any help, as I'm not getting the diff time I need. Instead I get this error:
In eval_tidy(xs[[i]], unique_output) : NAs introduced by coercion
Here's my code:
db <- dados%>%
select(Employee, Leaving.Reason, Entry.date.into.Group, Age, time.in.company, Termination.Date,
Salary, Promotion.Increase, Valid.Since.Promotion)%>%
group_by(Employee) %>%
group_split() %>%
lapply(function(x) {
x <- x %>%
arrange(desc(Salary))
tibble(
Employee = unique(x$Employee),
N = nrow(x),
Time_since_last_promo = as.integer(difftime(max(x$Entry.date.into.Group),
max(x$Valid.Since.Promotion),units = "days")),
N_promo = length(unique(x$Valid.Since.Promotion)),
timein=as.numeric(as.character(x$time.in.company)),
reason=x$Leaving.Reason
)
}) %>%
bind_rows()