MyPimpstyle
MyPimpstyle

Reputation: 1

Error in as.Date.default(e2) : do not know how to convert 'e2' to class “Date”

I am trying to get a new month's start date with mutate from dplyr. The function worked perfectly last night and now out of the blue I get the following error:

Error in as.Date.default(e2) : 
  do not know how to convert 'e2' to class “Date”

I never heard or read anything about "e2". Below my code and the head of my data:

CT_inact_months <- CT_inact_months %>%
  mutate(new_start_date = if_else(forced_start == newmonth, as.Date(start), as.Date(paste0(newmonth, "-01"))))
> head(CT_inact_months)
# A tibble: 6 × 8
 
 camera start               end                 forced_start forced_end name   newmonth  Year
  <chr>  <dttm>              <dttm>              <date>       <date>     <chr>  <I<chr>> <dbl>
1 K_A03  2019-02-19 22:43:00 2019-02-20 08:12:00 2019-02-01   2019-02-01 Month1 2019-02   2019
2 K_A03  2019-05-01 21:07:00 2019-05-02 23:44:00 2019-05-01   2019-05-01 Month1 2019-05   2019
3 K_A03  2019-08-07 02:58:00 2019-08-08 12:53:00 2019-08-01   2019-08-01 Month1 2019-08   2019
4 K_A03  2019-09-17 02:16:00 2019-11-11 06:56:00 2019-09-01   2019-11-01 Month1 2019-09   2019
5 K_A03  2019-09-17 02:16:00 2019-11-11 06:56:00 2019-09-01   2019-11-01 Month2 2019-10   2019
6 K_A03  2019-09-17 02:16:00 2019-11-11 06:56:00 2019-09-01   2019-11-01 Month3 2019-11   2019

I tried to supply as.Date with the "origin" as I thought that might be the issue. Also the as.Date parts of the code work on their own as I tried them separately.

Upvotes: 0

Views: 78

Answers (0)

Related Questions