1
我正在嘗試創建一個變量,指出財務年度某個事務已完成的哪個季度。因此,我需要定製四分之一變量的開始和結束日期。定製R上的季度日期
dt <- data.table(
date = c("2016-09-26", "2016-10-14", "2017-01-09"),
value = c(42, 87, 102),
location = c("a","b","c"))
dt$date <- as.Date(dt$date, "%m/%d/%Y")
我已經使用此代碼嘗試,但它返回「在休息無效規範」 ......
dt$quarter <- cut(dt$date,
breaks=c(-Inf, "2016-07-26", "2016-12-31", Inf),
labels=c("Q3-2016","Q4-2016","Q1-2017""))
我如何能重新編碼這有什麼建議?
也許這個頁面將是有益的[https://stackoverflow.com/questions/33877714/assigning-dates-to-fiscal-year](https://stackoverflow.com/questions/ 33877714 /分配日期到財年) –