【问题标题】:Zoo error: length(time(x)) == length(by[[1]]) is not TRUE动物园错误:长度(时间(x))==长度(按[[1]])不正确
【发布时间】:2015-09-07 11:49:16
【问题描述】:

我正在尝试根据 Hargreaves Samani 方法使用 this package 从气候数据中计算蒸散量

我正在处理的 csv 格式的数据是可用的 here,我正在使用的代码(使用 cmets)在下面

## 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】:

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

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

    希望对您有所帮助。

    【讨论】:

    • 我已经很久没有问这个问题了,很高兴看到答案,我不记得我最终是如何解决这个问题的,但这可能对其他人有所帮助。谢谢你:)
    猜你喜欢
    • 1970-01-01
    • 2018-07-27
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    • 2020-06-14
    相关资源
    最近更新 更多