我有以下问题。我有2006年到2100年之间的模型数据,但每个月都有30天,这意味着日历格式为360天。是否有可能将chron中的日历格式更改为此格式? “此格式”表示我每个月有30天。使用下面的方法,chron使用普通的日历格式。
转换后的时间戳开始于(12 / Mar / 2005 12:00:00)而不是正确的(1 / Jan / 2006 12:00:00)并使用正常的日历格式,您可以看到,当您试试代码并使用子集。
time.reconf <- chron(time, origin = c(12, 1, 1949),format = c(dates = "dd/mm/yyyy", times = "h:m:s"))
以下数据是时间的一个子集:
structure(c(20190.5, 20191.5, 20192.5, 20193.5, 20194.5, 20195.5,
20196.5, 20197.5, 20198.5, 20199.5, 20200.5, 20201.5, 20202.5,
20203.5, 20204.5, 20205.5, 20206.5, 20207.5, 20208.5, 20209.5,
20210.5, 20211.5, 20212.5, 20213.5, 20214.5, 20215.5, 20216.5,
20217.5, 20218.5, 20219.5, 20220.5, 20221.5, 20222.5, 20223.5,
20224.5, 20225.5, 20226.5, 20227.5, 20228.5, 20229.5, 20230.5,
20231.5, 20232.5, 20233.5, 20234.5, 20235.5, 20236.5, 20237.5,
20238.5, 20239.5, 20240.5, 20241.5, 20242.5, 20243.5, 20244.5,
20245.5, 20246.5, 20247.5, 20248.5, 20249.5, 20250.5, 20251.5,
20252.5, 20253.5, 20254.5, 20255.5, 20256.5, 20257.5, 20258.5,
20259.5, 20260.5, 20261.5, 20262.5, 20263.5, 20264.5, 20265.5,
20266.5, 20267.5, 20268.5, 20269.5, 20270.5, 20271.5, 20272.5,
20273.5, 20274.5, 20275.5, 20276.5, 20277.5, 20278.5, 20279.5,
20280.5, 20281.5, 20282.5, 20283.5, 20284.5, 20285.5, 20286.5,
20287.5, 20288.5, 20289.5, 20290.5, 20291.5, 20292.5, 20293.5,
20294.5, 20295.5, 20296.5, 20297.5, 20298.5, 20299.5, 20300.5,
20301.5, 20302.5, 20303.5, 20304.5, 20305.5, 20306.5, 20307.5,
20308.5, 20309.5, 20310.5, 20311.5, 20312.5, 20313.5, 20314.5,
20315.5, 20316.5, 20317.5, 20318.5, 20319.5, 20320.5, 20321.5,
20322.5, 20323.5, 20324.5, 20325.5, 20326.5, 20327.5, 20328.5,
20329.5, 20330.5, 20331.5, 20332.5, 20333.5, 20334.5, 20335.5,
20336.5, 20337.5, 20338.5, 20339.5, 20340.5, 20341.5, 20342.5,
20343.5, 20344.5, 20345.5, 20346.5, 20347.5, 20348.5, 20349.5,
20350.5, 20351.5, 20352.5, 20353.5, 20354.5, 20355.5, 20356.5,
20357.5, 20358.5, 20359.5, 20360.5, 20361.5, 20362.5, 20363.5,
20364.5, 20365.5, 20366.5, 20367.5, 20368.5, 20369.5, 20370.5,
20371.5, 20372.5, 20373.5, 20374.5, 20375.5, 20376.5, 20377.5,
20378.5, 20379.5, 20380.5, 20381.5, 20382.5, 20383.5, 20384.5,
20385.5, 20386.5, 20387.5, 20388.5, 20389.5, 20390.5, 20391.5,
20392.5, 20393.5, 20394.5, 20395.5, 20396.5, 20397.5, 20398.5,
20399.5, 20400.5, 20401.5, 20402.5, 20403.5, 20404.5, 20405.5,
20406.5, 20407.5, 20408.5, 20409.5, 20410.5, 20411.5, 20412.5,
20413.5, 20414.5, 20415.5, 20416.5, 20417.5, 20418.5, 20419.5,
20420.5, 20421.5, 20422.5, 20423.5, 20424.5, 20425.5, 20426.5,
20427.5, 20428.5, 20429.5, 20430.5, 20431.5, 20432.5, 20433.5,
20434.5, 20435.5, 20436.5, 20437.5, 20438.5, 20439.5, 20440.5,
20441.5, 20442.5, 20443.5, 20444.5, 20445.5, 20446.5, 20447.5,
20448.5, 20449.5, 20450.5, 20451.5, 20452.5, 20453.5, 20454.5,
20455.5, 20456.5, 20457.5, 20458.5, 20459.5, 20460.5, 20461.5,
20462.5, 20463.5, 20464.5, 20465.5, 20466.5, 20467.5, 20468.5,
20469.5, 20470.5, 20471.5, 20472.5, 20473.5, 20474.5, 20475.5,
20476.5, 20477.5, 20478.5, 20479.5, 20480.5, 20481.5, 20482.5,
20483.5, 20484.5, 20485.5, 20486.5, 20487.5, 20488.5, 20489.5,
20490.5, 20491.5, 20492.5, 20493.5, 20494.5, 20495.5, 20496.5,
20497.5, 20498.5, 20499.5, 20500.5, 20501.5, 20502.5, 20503.5,
20504.5, 20505.5, 20506.5, 20507.5, 20508.5, 20509.5, 20510.5,
20511.5, 20512.5, 20513.5, 20514.5, 20515.5, 20516.5, 20517.5,
20518.5, 20519.5, 20520.5, 20521.5, 20522.5, 20523.5, 20524.5,
20525.5, 20526.5, 20527.5, 20528.5, 20529.5, 20530.5, 20531.5,
20532.5, 20533.5, 20534.5, 20535.5, 20536.5, 20537.5, 20538.5,
20539.5, 20540.5, 20541.5, 20542.5, 20543.5, 20544.5, 20545.5,
20546.5, 20547.5, 20548.5, 20549.5, 20550.5, 20551.5, 20552.5,
20553.5, 20554.5, 20555.5, 20556.5, 20557.5, 20558.5, 20559.5,
20560.5, 20561.5, 20562.5, 20563.5, 20564.5, 20565.5, 20566.5,
20567.5, 20568.5, 20569.5, 20570.5, 20571.5, 20572.5, 20573.5,
20574.5, 20575.5, 20576.5, 20577.5, 20578.5, 20579.5), .Dim = 390L)
答案 0 :(得分:2)
我已将您的时间序列更改为普通向量
function titleCase2(str) {
str = str.split(' ').map(function(i, index) {
return i[0].toUpperCase() + i.substr(1).toLowerCase()
}).join(' ')
return str;
}
console.log(titleCase2("I'm a liTTle tea pot"));
其次,我已经安装了 PCICt 包
time <- c(20190.5, 20191.5, 20192.5, 20193.5, 20194.5, 20195.5,
20196.5, 20197.5, 20198.5, 20199.5, 20200.5, 20201.5, 20202.5,
20203.5, 20204.5, 20205.5, 20206.5, 20207.5, 20208.5, 20209.5,
...
20567.5, 20568.5, 20569.5, 20570.5, 20571.5, 20572.5, 20573.5,
20574.5, 20575.5, 20576.5, 20577.5, 20578.5, 20579.5)
您可以在此处设置 360
上的参数install.packages('PCICt')
library(PCICt)
将开始日期设置为 2006-01-01
cal <- "360_day"
并编辑,时间序列,如果结构与您提供的相同(如果错误则纠正我),从所有其他日期减去第一个日期应该是正确的。因此: [20190.5,20191.5,20192.5,20193.5 ......] 将变为 [0 1 2 3 ...] 。因此,0与2006-01-01相同,1是2006-01-02 - 2是2006-01-03等
origin <- "2006-01-01"
seconds.per.day <- 60*60*24
打印系列
ts.dat.days <- time - time[1]
origin.pcict <- as.PCICt(origin, cal)
ts.dat.pcict <- origin.pcict + (ts.dat.days * seconds.per.day)