相关疑难解决方法(0)

为什么apply()返回一个转置的xts矩阵?

我想在xts矩阵的所有周期上运行一个函数.apply()非常快,但返回的矩阵与原始对象相比具有转置尺寸:

> dim(myxts)
[1] 7429   48
> myxts.2 = apply(myxts, 1 , function(x) { return(x) })
> dim(myxts.2)
[1]   48 7429
> str(myxts)
An 'xts' object from 2012-01-03 09:30:00 to 2012-01-30 16:00:00 containing:
  Data: num [1:7429, 1:48] 4092500 4098500 4091500 4090300 4095200 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:48] "Open" "High" "Low" "Close" ...
  Indexed by objects of class: [POSIXlt,POSIXt] TZ: 
  xts Attributes:  
 NULL
> str(myxts.2)
 num [1:48, 1:7429] 4092500 4098500 4091100 4098500 0 …
Run Code Online (Sandbox Code Playgroud)

r apply xts

12
推荐指数
1
解决办法
5174
查看次数

标签 统计

apply ×1

r ×1

xts ×1