mutate_at 列名错误
mutate_at column names error
我正在尝试将 dplyr 链中 anytime 包中的 anytime() 函数应用于所有以 Date
结尾的列
但是我遇到了这个错误。
Error: Unsupported Type
当我使用
invoicePayment <- head(raw.InvoicePayment) %>%
mutate_at(ends_with("Date"), funs(anytime))
但是我用的时候没问题
invoicePayment <- head(raw.InvoicePayment) %>%
select(ends_with("Date")) %>%
mutate_at(ends_with("Date"), funs(anytime))
感谢任何帮助,
谢谢,
我们可能需要用 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)
我正在尝试将 dplyr 链中 anytime 包中的 anytime() 函数应用于所有以 Date
结尾的列但是我遇到了这个错误。
Error: Unsupported Type
当我使用
invoicePayment <- head(raw.InvoicePayment) %>%
mutate_at(ends_with("Date"), funs(anytime))
但是我用的时候没问题
invoicePayment <- head(raw.InvoicePayment) %>%
select(ends_with("Date")) %>%
mutate_at(ends_with("Date"), funs(anytime))
感谢任何帮助, 谢谢,
我们可能需要用 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)