I have a list of xts
objects. The objects are monthly time series and I'd like to aggregate them up to quarterly. Using the either to.quarterly
or apply.quarterly
fails through lapply
:
我有一个xts对象列表。对象是月时间序列,我想将它们汇总成季度。使用要么。季度或应用。季度通过拉普兰人失败:
l.qtr <- lapply(l.adj, function(x) apply.quarterly(x, mean))
results in:
结果:
Error in try.xts(x, error = "must be either xts-coercible or timeBased") :
must be either xts-coercible or timeBased
However I can do it with another list of xts
objects I call lx
. This lx
list is sent off, converted to ts
objects, X12 adjusted and reclassed to xts
and sent back. Somehow when it comes back I get the error. I verified the problem doesn't exist for a list of size one, even after sending it off to be X12 adjusted.
但是我可以用另一个xts对象的列表来做,我称之为lx。这个lx列表被发送,转换为ts对象,X12调整并重新归类到xts并发回。当它回来的时候,我得到了误差。我验证了这个问题并不存在于一个大小为1的列表中,即使是在将它发送到X12调整之后。
Thinking it was a problem like at this link but doesn't seem to be? Automatically plot (and save) list of xts objects
认为这是一个问题,就像在这个环节,但似乎不是?自动绘图(和保存)xts对象列表。
Anymore excellent help? This is driving me nuts.
了优秀的帮助吗?这简直快把我逼疯了。
UPDATE: My apologies for the initial lack of focus. I've been trying to narrow this down to a tight reproducible example. It appears to be an interaction between my helper function SeasAdj
(which converts to ts
, deseasonalizes and converts back to a xts
) and the initial conversion of my data.frame
to an xts
. However If I run an xts
monthly series downloaded through quantmod's
getSymbols
I have the desired outcome. It leads me to believe the trouble is in how the SeasAdj helper function converts back to an xts
before returning. I have dput(lax)
at the end. From there running these four lines after sourcing SeasAdj:
更新:我为最初的缺乏关注而道歉。我一直试着把它缩小到一个可重复的例子。它似乎是我的助手函数(转换为ts、deseason和转换回xts)和初始化数据的初始转换之间的交互。但是如果我在quantmod的getSymbols中运行一个xts月系列,我就有了预期的结果。这让我相信,问题在于,在返回之前,如何将该函数转换回xts。我到最后都有dput(lax)。在采购季节之后,从那里运行这四条线:
lax.xts <- xts(lax$value, order.by=lax$date)
lax.adj <- SeasAdj(lax.xts)
lax.qtr <- apply.quarterly(lax.adj, mean)
lax.q <- apply.quarterly(lax.xts, mean)
SeasAdj <- function(x) {
require(x12)
require(quantmod)
freq <- switch(periodicity(x)$scale,
daily=365,
weekly=52,
monthly=12,
quarterly=4,
yearly=1)
## determine the start date from xts
pltStart <- as.POSIXlt(start(x))
# create 2 arg vector with year, month for start
Start <- c(pltStart$year+1900,pltStart$mon+1)
# capture xts series name
names <- dimnames(x)
#pass info as args to create ts
x.ts <- ts(x, start=Start, frequency=freq)
## use x12 automodel
# do some seasonal adjustment using x12
# return a TS object with data and seasonally adjusted data
x12out <- x12work(x.ts,
x12path="C:\\x12arima\\x12a.exe",
transform.function="auto",
automdl=TRUE)
# assign adjusted and original series to vectors
x.adj <- as.ts(x12out$d11)
x.orig <- as.ts(x12out$a1)
# convert to XTS
xts.adj <- as.xts(x.adj)
# assign dimname back to series
dimnames(xts.adj) <- names
# return XTS object
return(xts.adj)
}
Here is a dput of lax dput(lax)
这是一套松散的dput(lax)
structure(list(series_id = c("LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003",
"LAUCN55063003", "LAUCN55063003", "LAUCN55063003", "LAUCN55063003"
), year = c(1990L, 1990L, 1990L, 1990L, 1990L, 1990L, 1990L,
1990L, 1990L, 1990L, 1990L, 1990L, 1991L, 1991L, 1991L, 1991L,
1991L, 1991L, 1991L, 1991L, 1991L, 1991L, 1991L, 1991L, 1992L,
1992L, 1992L, 1992L, 1992L, 1992L, 1992L, 1992L, 1992L, 1992L,
1992L, 1992L, 1993L, 1993L, 1993L, 1993L, 1993L, 1993L, 1993L,
1993L, 1993L, 1993L, 1993L, 1993L, 1994L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1995L,
1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L,
1995L, 1995L, 1996L, 1996L, 1996L, 1996L, 1996L, 1996L, 1996L,
1996L, 1996L, 1996L, 1996L, 1996L, 1997L, 1997L, 1997L, 1997L,
1997L, 1997L, 1997L, 1997L, 1997L, 1997L, 1997L, 1997L, 1998L,
1998L, 1998L, 1998L, 1998L, 1998L, 1998L, 1998L, 1998L, 1998L,
1998L, 1998L, 1999L, 1999L, 1999L, 1999L, 1999L, 1999L, 1999L,
1999L, 1999L, 1999L, 1999L, 1999L, 2000L, 2000L, 2000L, 2000L,
2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2001L,
2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L,
2001L, 2001L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L,
2002L, 2002L, 2002L, 2002L, 2002L, 2003L, 2003L, 2003L, 2003L,
2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2004L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L,
2004L, 2004L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L,
2005L, 2005L, 2005L, 2005L, 2005L, 2006L, 2006L, 2006L, 2006L,
2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2007L,
2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
2007L, 2007L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L,
2008L, 2008L, 2008L, 2008L, 2008L, 2009L, 2009L, 2009L, 2009L,
2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2011L, 2011L, 2011L, 2011L, 2011L, 2012L, 2012L, 2012L, 2012L,
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2013L,
2013L, 2013L, 2013L, 2013L, 2013L), period = c("01", "02", "03",
"04", "05", "06", "07", "08", "09", "10", "11", "12", "01", "02",
"03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "01",
"02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12",
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11",
"12", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
"11", "12", "01", "02", "03", "04", "05", "06", "07", "08", "09",
"10", "11", "12", "01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12", "01", "02", "03", "04", "05", "06", "07",
"08", "09", "10", "11", "12", "01", "02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12", "01", "02", "03", "04", "05",
"06", "07", "08", "09", "10", "11", "12", "01", "02", "03", "04",
"05", "06", "07", "08", "09", "10", "11", "12", "01", "02", "03",
"04", "05", "06", "07", "08", "09", "10", "11", "12", "01", "02",
"03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "01",
"02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12",
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11",
"12", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
"11", "12", "01", "02", "03", "04", "05", "06", "07", "08", "09",
"10", "11", "12", "01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12", "01", "02", "03", "04", "05", "06", "07",
"08", "09", "10", "11", "12", "01", "02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12", "01", "02", "03", "04", "05",
"06", "07", "08", "09", "10", "11", "12", "01", "02", "03", "04",
"05", "06", "07", "08", "09", "10", "11", "12", "01", "02", "03",
"04", "05", "06", "07", "08", "09", "10", "11", "12", "01", "02",
"03", "04", "05", "06"), value = c(4.7, 5, 4.8, 3.6, 3.4, 3.5,
4, 3.4, 3.1, 3.1, 4, 4.1, 4.7, 5.2, 5.2, 4.1, 3.7, 4.5, 4.3,
3.6, 3.3, 3.5, 3.9, 4.2, 4.7, 5.3, 5, 4.1, 4.5, 5.2, 4.7, 4.3,
4, 3.6, 3.8, 3.9, 4.7, 5.2, 4.6, 3.9, 3.8, 4.4, 4.7, 4, 3.8,
3.6, 3.5, 3.8, 4.9, 5.1, 4.8, 3.9, 3.4, 3.9, 4.2, 3.5, 3, 2.6,
2.7, 2.8, 4.3, 4.7, 4.5, 4.2, 3.5, 4.1, 3.8, 3.5, 3, 2.9, 3.2,
3.2, 4.1, 4.5, 4.3, 3.2, 2.9, 3, 2.8, 2.6, 2.2, 2.1, 2.5, 2.6,
3.7, 3.6, 3.9, 3.1, 2.5, 2.8, 2.6, 2.5, 2.2, 2.1, 2.4, 2.4, 3.3,
3.3, 3.6, 2.3, 2.3, 3, 2.3, 2.6, 2.4, 2.4, 2.4, 2.5, 3.3, 3.7,
3.1, 2.6, 2.5, 3.1, 2.5, 3.2, 2.8, 2.7, 2.7, 3, 3.7, 3.9, 3.9,
3, 2.8, 3.5, 3.1, 3.1, 2.6, 2.5, 2.8, 2.9, 3.8, 4.1, 4.5, 3.7,
3.4, 3.9, 3.5, 3.6, 3.3, 3.2, 3.6, 3.8, 4.8, 5, 5.2, 4.7, 4.1,
4.6, 4.2, 4.2, 3.6, 3.5, 4, 4, 5.2, 5.6, 5.3, 4.6, 4.3, 5, 4.5,
4.4, 3.9, 3.8, 4, 3.9, 5.1, 5.1, 5.5, 4, 3.8, 4.4, 3.8, 3.8,
3.5, 3.3, 3.6, 3.5, 4.7, 5.1, 4.9, 3.8, 3.8, 4.3, 3.9, 3.8, 3.7,
3.3, 3.7, 3.8, 4.3, 4.5, 4.4, 3.8, 3.4, 4, 3.7, 3.6, 3.3, 3.1,
3.4, 3.6, 4.6, 4.5, 4.3, 3.8, 3.6, 4.2, 3.8, 3.6, 3.4, 3.3, 3.3,
3.6, 4, 4, 3.9, 3.2, 3.3, 4.2, 3.9, 3.9, 3.6, 3.7, 4.1, 4.8,
6.2, 7, 7.5, 6.7, 6.7, 7.6, 7, 6.9, 6.5, 6.3, 6.3, 6.7, 7.8,
7.7, 7.7, 6.3, 6.1, 6.4, 6.5, 6.2, 5.6, 5.4, 5.5, 5.4, 6.4, 6.6,
6.3, 5.6, 5.5, 6.6, 6.1, 5.9, 5.3, 5.1, 5, 5, 5.9, 6.2, 5.8,
4.9, 5.1, 6, 5.8, 5.5, 4.7, 4.6, 4.7, 4.9, 6.3, 6.3, 5.7, 5.3,
5.1, 5.7), footnote_codes = c("", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S",
"S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S",
"S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "E", "E", "E",
"E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E",
"E", "E", "E", "E", "E", "E", "E", "E", "", "", "", "", "", "P"
), date = structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0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94L, 94L, 94L, 94L, 95L, 95L, 95L, 95L, 95L, 95L, 95L,
95L, 95L, 95L, 95L, 95L, 96L, 96L, 96L, 96L, 96L, 96L, 96L,
96L, 96L, 96L, 96L, 96L, 97L, 97L, 97L, 97L, 97L, 97L, 97L,
97L, 97L, 97L, 97L, 97L, 98L, 98L, 98L, 98L, 98L, 98L, 98L,
98L, 98L, 98L, 98L, 98L, 99L, 99L, 99L, 99L, 99L, 99L, 99L,
99L, 99L, 99L, 99L, 99L, 100L, 100L, 100L, 100L, 100L, 100L,
100L, 100L, 100L, 100L, 100L, 100L, 101L, 101L, 101L, 101L,
101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 102L, 102L,
102L, 102L, 102L, 102L, 102L, 102L, 102L, 102L, 102L, 102L,
103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L,
103L, 103L, 104L, 104L, 104L, 104L, 104L, 104L, 104L, 104L,
104L, 104L, 104L, 104L, 105L, 105L, 105L, 105L, 105L, 105L,
105L, 105L, 105L, 105L, 105L, 105L, 106L, 106L, 106L, 106L,
106L, 106L, 106L, 106L, 106L, 106L, 106L, 106L, 107L, 107L,
107L, 107L, 107L, 107L, 107L, 107L, 107L, 107L, 107L, 107L,
108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L,
108L, 108L, 109L, 109L, 109L, 109L, 109L, 109L, 109L, 109L,
109L, 109L, 109L, 109L, 110L, 110L, 110L, 110L, 110L, 110L,
110L, 110L, 110L, 110L, 110L, 110L, 111L, 111L, 111L, 111L,
111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
113L, 113L, 113L, 113L, 113L, 113L), wday = c(1L, 4L, 4L,
0L, 2L, 5L, 0L, 3L, 6L, 1L, 4L, 6L, 2L, 5L, 5L, 1L, 3L, 6L,
1L, 4L, 0L, 2L, 5L, 0L, 3L, 6L, 0L, 3L, 5L, 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59L,
90L, 120L, 151L, 181L, 212L, 243L, 273L, 304L, 334L, 0L,
31L, 59L, 90L, 120L, 151L, 181L, 212L, 243L, 273L, 304L,
334L, 0L, 31L, 60L, 91L, 121L, 152L, 182L, 213L, 244L, 274L,
305L, 335L, 0L, 31L, 59L, 90L, 120L, 151L, 181L, 212L, 243L,
273L, 304L, 334L, 0L, 31L, 59L, 90L, 120L, 151L, 181L, 212L,
243L, 273L, 304L, 334L, 0L, 31L, 59L, 90L, 120L, 151L, 181L,
212L, 243L, 273L, 304L, 334L, 0L, 31L, 60L, 91L, 121L, 152L,
182L, 213L, 244L, 274L, 305L, 335L, 0L, 31L, 59L, 90L, 120L,
151L, 181L, 212L, 243L, 273L, 304L, 334L, 0L, 31L, 59L, 90L,
120L, 151L, 181L, 212L, 243L, 273L, 304L, 334L, 0L, 31L,
59L, 90L, 120L, 151L, 181L, 212L, 243L, 273L, 304L, 334L,
0L, 31L, 60L, 91L, 121L, 152L, 182L, 213L, 244L, 274L, 305L,
335L, 0L, 31L, 59L, 90L, 120L, 151L, 181L, 212L, 243L, 273L,
304L, 334L, 0L, 31L, 59L, 90L, 120L, 151L, 181L, 212L, 243L,
273L, 304L, 334L, 0L, 31L, 59L, 90L, 120L, 151L, 181L, 212L,
243L, 273L, 304L, 334L, 0L, 31L, 60L, 91L, 121L, 152L, 182L,
213L, 244L, 274L, 305L, 335L, 0L, 31L, 59L, 90L, 120L, 151L,
181L, 212L, 243L, 273L, 304L, 334L, 0L, 31L, 59L, 90L, 120L,
151L, 181L, 212L, 243L, 273L, 304L, 334L, 0L, 31L, 59L, 90L,
120L, 151L, 181L, 212L, 243L, 273L, 304L, 334L, 0L, 31L,
60L, 91L, 121L, 152L, 182L, 213L, 244L, 274L, 305L, 335L,
0L, 31L, 59L, 90L, 120L, 151L, 181L, 212L, 243L, 273L, 304L,
334L, 0L, 31L, 59L, 90L, 120L, 151L, 181L, 212L, 243L, 273L,
304L, 334L, 0L, 31L, 59L, 90L, 120L, 151L, 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 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L,
0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L)), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
), class = c("POSIXlt", "POSIXt"))), .Names = c("series_id",
"year", "period", "value", "footnote_codes", "date"), row.names = c(40841L,
40842L, 40843L, 40844L, 40845L, 40846L, 40847L, 40848L, 40849L,
40850L, 40851L, 40852L, 40854L, 40855L, 40856L, 40857L, 40858L,
40859L, 40860L, 40861L, 40862L, 40863L, 40864L, 40865L, 40867L,
40868L, 40869L, 40870L, 40871L, 40872L, 40873L, 40874L, 40875L,
40876L, 40877L, 40878L, 40880L, 40881L, 40882L, 40883L, 40884L,
40885L, 40886L, 40887L, 40888L, 40889L, 40890L, 40891L, 40893L,
40894L, 40895L, 40896L, 40897L, 40898L, 40899L, 40900L, 40901L,
40902L, 40903L, 40904L, 40906L, 40907L, 40908L, 40909L, 40910L,
40911L, 40912L, 40913L, 40914L, 40915L, 40916L, 40917L, 40919L,
40920L, 40921L, 40922L, 40923L, 40924L, 40925L, 40926L, 40927L,
40928L, 40929L, 40930L, 40932L, 40933L, 40934L, 40935L, 40936L,
40937L, 40938L, 40939L, 40940L, 40941L, 40942L, 40943L, 40945L,
40946L, 40947L, 40948L, 40949L, 40950L, 40951L, 40952L, 40953L,
40954L, 40955L, 40956L, 40958L, 40959L, 40960L, 40961L, 40962L,
40963L, 40964L, 40965L, 40966L, 40967L, 40968L, 40969L, 40971L,
40972L, 40973L, 40974L, 40975L, 40976L, 40977L, 40978L, 40979L,
40980L, 40981L, 40982L, 40984L, 40985L, 40986L, 40987L, 40988L,
40989L, 40990L, 40991L, 40992L, 40993L, 40994L, 40995L, 40997L,
40998L, 40999L, 41000L, 41001L, 41002L, 41003L, 41004L, 41005L,
41006L, 41007L, 41008L, 41010L, 41011L, 41012L, 41013L, 41014L,
41015L, 41016L, 41017L, 41018L, 41019L, 41020L, 41021L, 41023L,
41024L, 41025L, 41026L, 41027L, 41028L, 41029L, 41030L, 41031L,
41032L, 41033L, 41034L, 41036L, 41037L, 41038L, 41039L, 41040L,
41041L, 41042L, 41043L, 41044L, 41045L, 41046L, 41047L, 41049L,
41050L, 41051L, 41052L, 41053L, 41054L, 41055L, 41056L, 41057L,
41058L, 41059L, 41060L, 41062L, 41063L, 41064L, 41065L, 41066L,
41067L, 41068L, 41069L, 41070L, 41071L, 41072L, 41073L, 41075L,
41076L, 41077L, 41078L, 41079L, 41080L, 41081L, 41082L, 41083L,
41084L, 41085L, 41086L, 41088L, 41089L, 41090L, 41091L, 41092L,
41093L, 41094L, 41095L, 41096L, 41097L, 41098L, 41099L, 41101L,
41102L, 41103L, 41104L, 41105L, 41106L, 41107L, 41108L, 41109L,
41110L, 41111L, 41112L, 41114L, 41115L, 41116L, 41117L, 41118L,
41119L, 41120L, 41121L, 41122L, 41123L, 41124L, 41125L, 41127L,
41128L, 41129L, 41130L, 41131L, 41132L, 41133L, 41134L, 41135L,
41136L, 41137L, 41138L, 41140L, 41141L, 41142L, 41143L, 41144L,
41145L), class = "data.frame")
1 个解决方案
#1
1
Works for me
适合我
library(quantmod)
e <- new.env()
s <- c("SPY", "DIA", "GLD")
getSymbols(s, env=e)
l.adj <- eapply(e, Ad)[s]
l.qtr <- lapply(l.adj, function(x) apply.quarterly(x, mean))
Edit
编辑
The code is still not reproducible (or minimal), but dimnames(xts.adj) <- names
looks suspicious. It looks like you are setting dimnames to NULL (see lapply(split(lax.xts, "quarters"), dimnames)
)
代码仍然不能复制(或最小化),但是dimnames(xts) <-名称看起来可疑。看起来您正在将dimname设置为NULL(参见lapply(split(lax))。xt,“季度”),dimnames))
If you set the dimnames of an xts to NULL, you end up turning it into something that as.xts
cannot convert to an xts
. I think this is probably not the intended behavior of xts:::`dimnames<-.xts`
.
如果将xts的dimname设置为NULL,那么就会将其转换成某种形式。xts不能转换为xts。我认为这可能不是xts的预期行为::“dimnames<-.xts”。
Since I couldn't run your code, I don't know for sure that this is the problem, but if it is, here is a much more concise reproducible example.
由于我不能运行您的代码,我不确定这是不是问题,但如果是,这里有一个更简洁的可复制示例。
x <- xts(1:5, .POSIXct(0)+1:5)
dimnames(x) <- dimnames(x)
as.xts(x)
#Error in as.xts.matrix(x) :
# order.by must be either 'rownames()' or otherwise specified
#1
1
Works for me
适合我
library(quantmod)
e <- new.env()
s <- c("SPY", "DIA", "GLD")
getSymbols(s, env=e)
l.adj <- eapply(e, Ad)[s]
l.qtr <- lapply(l.adj, function(x) apply.quarterly(x, mean))
Edit
编辑
The code is still not reproducible (or minimal), but dimnames(xts.adj) <- names
looks suspicious. It looks like you are setting dimnames to NULL (see lapply(split(lax.xts, "quarters"), dimnames)
)
代码仍然不能复制(或最小化),但是dimnames(xts) <-名称看起来可疑。看起来您正在将dimname设置为NULL(参见lapply(split(lax))。xt,“季度”),dimnames))
If you set the dimnames of an xts to NULL, you end up turning it into something that as.xts
cannot convert to an xts
. I think this is probably not the intended behavior of xts:::`dimnames<-.xts`
.
如果将xts的dimname设置为NULL,那么就会将其转换成某种形式。xts不能转换为xts。我认为这可能不是xts的预期行为::“dimnames<-.xts”。
Since I couldn't run your code, I don't know for sure that this is the problem, but if it is, here is a much more concise reproducible example.
由于我不能运行您的代码,我不确定这是不是问题,但如果是,这里有一个更简洁的可复制示例。
x <- xts(1:5, .POSIXct(0)+1:5)
dimnames(x) <- dimnames(x)
as.xts(x)
#Error in as.xts.matrix(x) :
# order.by must be either 'rownames()' or otherwise specified