我正在尝试将我的数据框过滤到该财年(10-01-2018 / 09-31-2019)内的日期。
我以为这会更简单,但我一直收到一个错误。
Error in charToDate(x) :
character string is not in a standard unambiguous format
这是我正在尝试的:
数据集:
toStata <- structure(list(`Advance Identifier` = c("A00010001", "A00010001",
"A00010001", "A00010001", "A00010001"), `Date Due` = structure(c(1312934400,
1317772800, 1325721600, 1333584000, 1341446400), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), Disbursement = c(85740440.38, 0, 0,
0, 0), `Principal Due` = c(0, 0, 0, 0, 0), `Interest Due` = c(0,
425817.56, 699557.43, 691953.54, 691953.54), `Capitalized Interest Due` = c(0,
0, 0, 0, 0), `Repayment Timing` = c("Beginning", "Beginning",
"Beginning", "Beginning", "Beginning"), `Disbursement Timing` = c("Beginning",
"Beginning", "Beginning", "Beginning", "Beginning"), `Capitalized Interest` = c(0,
0, 0, 0, 0), Payment = c(0, 425817.56, 699557.43, 691953.54,
691953.54), `Cash Grant Amount` = c(0, 0, 0, 0, 0), `Cash Grant Prepayment Effect Principal` = c(0,
0, 0, 0, 0), `Cash Grant Prepayment Effect Interest` = c(0, 0,
0, 0, 0), `Cash Grant Prepayment Effect Capitalized Interest` = c(0,
0, 0, 0, 0), `Interest Rate` = c(0.03237, 0.03237, 0.03237, 0.03237,
0.03237), `Payment Frequency` = c("Quarterly", "Quarterly", "Quarterly",
"Quarterly", "Quarterly"), `Modification Principal` = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_), `Modification Interest` = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_), `Modification Capitalized Interest` = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_)), row.names = c(NA, -5L
), class = c("tbl_df", "tbl", "data.frame"))
library(tidyverse)
file <- toStata %>%
filter('Date Due' >= as.Date("2010-10-01", format = "%Y-%m-%d") & 'Date Due' <= as.Date("2011-09-31", format = "%Y-%m-%d"))
也许我有太多的细节?不确定,尽管我在每个转弯时都收到错误;任何替代方案都会有帮助!
发布于 2019-07-03 00:12:35
30天有9月,4月,6月和11月...在filter()
中查看你的第二次约会
此外,如果变量名中包含非法字符(如空格),则需要使用反引号。
https://stackoverflow.com/questions/56855812
复制相似问题