R: Why an xts object becomes a zoo object after calling transform()?

社会主义新天地 提交于 2019-12-06 04:29:25

There's no xts method for transform, so the zoo method is dispatched. The zoo method explicitly creates a new zoo object.

> zoo:::transform.zoo
function (`_data`, ...) 
{
    if (is.null(dim(coredata(`_data`)))) 
        warning("transform() is only useful for matrix-based zoo series")
    zoo(transform.data.frame(data.frame(coredata(`_data`)), ...), 
        index(`_data`), attr(`_data`, "frequency"))
}
<environment: namespace:zoo>

You could simply wrap your transform calls in as.xts, or your example could be written as myxts$ABC <- 1.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!