Zoo错误:length(time(x))== length(by [[1]])不为TRUE

时间:2015-09-07 11:49:16

标签: r zoo

我试图根据Hargreaves Samani方法使用this package

来计算气候数据的蒸散量

我以csv格式处理的数据可用here,我使用的代码(带注释)位于

之下
## Using Evapotranspiration package to get DAILY PE ###
require(Evapotranspiration)
require(zoo)

#load the constants required from the Evapotranspiration package
data("constants")

#converting the CSV to a zoo object
OakPark<- read.csv("OakParkR.csv", header=TRUE)

#Fill the blanks in the csv with NAs
na.fill(OakPark,NA)

#convert to a zoo
OakPark <- as.zoo(OakPark)

#create a zoo series with the required variables
PE.data <- OakPark[ ,c(3,5)]

#converting to a list as ET function works on a list
PE.data <- as.list(PE.data)

#change constants to the local values
constants$Elev = 62
constants$lat_rad = 0.9226

#defining the function
funname <- "HargreavesSamani"
class(PE.data) <- funname

#creating a new variable with the calculation
results <- ET(PE.data,constants)

然后错误显示:

Error: length(time(x)) == length(by[[1]]) is not TRUE

我已经查看了其他帮助部分,例如this,但无法看到我如何实现此功能,以便它可以处理这个内置的HargreavesSamani函数。

1 个答案:

答案 0 :(得分:1)

在同一包(ReadInputs)包中使用Evapotranspiration函数来预处理数据并构造输入数据。 不要自己创建输入数据。

当我尝试自己创建输入数据时,遇到了相同的错误。 我相信使用ReadInputs函数是解决此问题的最佳方法。

希望获得帮助。