function rep() 有一个例子:
x <- .leap.seconds[1:3]
x
#[1] "1972-07-01 08:00:00 CST" "1973-01-01 08:00:00 CST" "1974-01-01 08:00:00 CST"
rep(x, 2)
#[1] "1972-07-01 08:00:00 CST" "1973-01-01 08:00:00 CST" "1974-01-01 08:00:00 CST" "1972-07-01 08:00:00 CST" "1973-01-01 08:00:00 CST"
#[6] "1974-01-01 08:00:00 CST"
rep(as.POSIXlt(x), rep(2, 3))
#[1] "1972-07-01 08:00:00 CST" "1973-01-01 08:00:00 CST" "1974-01-01 08:00:00 CST" "1972-07-01 08:00:00 CST" "1973-01-01 08:00:00 CST"
#[6] "1974-01-01 08:00:00 CST"
rep(2,3) 的结果应该是输出 2 2 2,然后 rep(as.POSIXlt(x), rep(2, 3))这个语句输出以上结果,该如何解释?
|