Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206235

Attempting to diff two times results in "NAs introduced by coercion" error

$
0
0

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()

Viewing all articles
Browse latest Browse all 206235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>