我read.zoo
用来将制表符分隔的数据文件读入动物园时间序列。我有以下代码:
z <- read.zoo("poolBL03GD04_842_WMO_03862.tts", index=2:5, FUN = conv)
据我了解,这是将read.zoo
函数的结果分配给z
变量,但它也会打印出整个结果read.zoo
。为什么会这样,我该如何阻止它?
更新了可重现的示例:
library(chron)
library(zoo)
conv <- function(y,m,d,t) {
date_str <- paste(m,"/", d, "/", y, " ", sep="")
time_str <- paste(t, ":00", sep="")
print(date_str)
print(time_str)
chron(date_str, time_str)
}
zz <- textConnection("51645 2000 04 11 00:00 2367.35 80.9 12.5
51645 2000 04 11 01:00 2370.38 88.8 13.7
51645 2000 04 11 02:00 2357.50 80.6 12.5
51645 2000 04 11 03:00 2360.38 87.2 13.5
51645 2000 04 11 04:00 2354.70 84.0 12.9
51645 2000 04 11 05:00 2345.91 79.3 12.2")
z <- read.zoo(zz, index=2:5, FUN = conv, header=F)
read.zoo
当尝试从函数中使用时,这更加令人沮丧。
有谁知道为什么会这样?