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

问题描述 投票:3回答:1

我正在尝试使用this package基于Hargreaves Samani方法研究气候数据的蒸散量

我正在以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函数。

r zoo
1个回答
1
投票

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

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

希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.