【发布时间】:2013-05-30 13:06:23
【问题描述】:
我试图找到 nrows(df) 的最大行数 2:5、3:6、4:7 等等。然而,我在思考如何做到这一点时遇到了问题,因为我过去从未成功使用过 for 循环。非常感谢任何帮助。
structure(c(76.89, 77.08, 77.05, 77.28, 77.28, 77.61, 77.03,
77.61, 77.28, 77.3, 77.37, 77.61, 76.7, 77, 76.98, 77.09, 77.21,
77.5, 76.74, 77.49, 76.98, 77.2, 77.29, 77.58, NA, 76.91, 77.27,
77.13, 77.24, 77.45, NA, 0.910154726303475, 0.0129416332341208,
0.220407104887854, 0.168306576903153, 0.20658489347966, NA, 0.117019893381879,
-0.3753073637893, -0.0518604952677195, -0.0388399792853642, 0.0645577792123914
), .indexCLASS = "Date", .indexTZ = "UTC", tclass = "Date", tzone = "UTC", class = c("xts",
"zoo"), index = structure(c(631324800, 631411200, 631497600,
631756800, 631843200, 631929600), tzone = "UTC", tclass = "Date"), .Dim = 6:7, .Dimnames = list(
NULL, c("open", "high", "low", "close", "avgco", "percenthigh",
"percentlow")))
具体来说,我想在 AD1$high 列上应用 max 函数,用于第 2 到 5 行,然后是第 3 到 6 行,依此类推,并将其放在新列中。
谢谢
【问题讨论】: