I'm trying to apply the anytime() function from the anytime package in a dplyr chain to all columns ending with Date
I'm however getting this error.
Error: Unsupported Type
when I use
invoicePayment <- head(raw.InvoicePayment) %>%
mutate_at(ends_with("Date"), funs(anytime))
but it's fine when I use
invoicePayment <- head(raw.InvoicePayment) %>%
select(ends_with("Date")) %>%
mutate_at(ends_with("Date"), funs(anytime))
Any help is appreciated, Thanks,
We may need to wrap with vars
library(anytime)
library(dplyr)
df1 %>%
mutate_at(vars(ends_with("Date")), anytime)
# col1 col2_Date col3_Date
#1 1 2017-06-07 05:30:00 2017-06-07 05:30:00
#2 2 2017-06-08 05:30:00 2017-06-06 05:30:00
#3 3 2017-06-09 05:30:00 2017-06-05 05:30:00
#4 4 2017-06-10 05:30:00 2017-06-04 05:30:00
#5 5 2017-06-11 05:30:00 2017-06-03 05:30:00
df1 <- data.frame(col1 = 1:5, col2_Date = Sys.Date() + 0:4, col3_Date = Sys.Date() - 0:4)