i try convert date format
tt=structure(list(gr = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), date = c("2021-01-02 11:53:53.0000000",
"2021-01-02 11:54:00.0000000", "2021-01-02 10:00:46.0000000",
"2021-01-02 10:00:23.0000000", "2021-01-02 10:09:00.0000000",
"2021-01-02 11:05:01.0000000", "2021-01-02 11:03:49.0000000",
"2021-01-02 13:24:02.0000000", "2021-01-02 13:24:02.0000000",
"2021-01-02 13:39:40.0000000", "2021-01-02 13:39:40.0000000",
"2021-01-02 13:39:40.0000000", "2021-01-02 13:39:40.0000000",
"2021-01-02 13:39:40.0000000", "2021-01-02 13:39:40.0000000",
"2021-01-02 13:24:02.0000000", "2021-01-02 13:24:02.0000000",
"2021-01-02 13:24:02.0000000", "2021-01-02 13:24:02.0000000",
"2021-01-02 12:57:00.0000000"), metric = c(23749.14, 1000, 3050,
1550, 8900, 1550, 0, 300, 0, 499, 5450, 300, 0, 499, 599, 599,
6050, 300, 599, 1400)), class = "data.frame", row.names = c(NA,
-20L))
i use this way,but something goes wrong
tibble(tt) %>%
mutate(date = mdy(date),
date_time = ymd_hms(format(date, "%Y-%m-%d 00:00:00")),
week_num = week(date),
weekday = weekdays(date)) %>%
select(sales_count, date_time, date, week_num, weekday)
and got the error
Problem with `mutate()` input `index_date`.
i All formats failed to parse. No formats found.
i Input `index_date` is `dmy(date)`
and variables with NA. But i need that result was something like this
metric date_time date week_num weekday gr
1 10 2021-01-01 00:00:00 2021-01-01 1 Friday 2
2 4 2021-01-01 00:00:00 2021-01-01 1 Friday 2
3 8 2021-01-01 00:00:00 2021-01-01 1 Friday 2
4 6 2021-01-01 00:00:00 2021-01-01 1 Friday 2
5 4 2021-01-01 00:00:00 2021-01-01 1 Friday 2
6 4 2021-01-01 00:00:00 2021-01-01 1 Friday 2
7 4 2021-01-01 00:00:00 2021-01-01 1 Friday 2
8 3 2021-01-01 00:00:00 2021-01-01 1 Friday 2
9 1 2021-01-01 00:00:00 2021-01-01 1 Friday 2
10 5 2021-01-01 00:00:00 2021-01-01 1 Friday 2
11 2 2021-01-01 00:00:00 2021-01-01 1 Friday 2
How correct do it to get desired output? thank you.