> w
A B
1998-01-08 -0.0051653999 0.007
1998-01-09 0.0064191599 -0.008
1998-01-12 -0.0018169993 0.009
1998-01-13 0.0046482541 -0.005
1998-01-14 0.0080997329 -0.006
1998-01-15 -0.0007764179 0.008
c<-(-0.5,-0.6,-0.7,0.1,0.2,0.3)
我想创建一个矩阵,其中一列从 w 中选择 A 或 B,条件是 c > 0
IE
w[,if (c<0) A else B]
C
1998-01-08 -0.0051653999
1998-01-09 0.0064191599
1998-01-12 -0.0018169993
1998-01-13 -0.005
1998-01-14 -0.006
1998-01-15 0.008