gpt4 book ai didi

r - 动物园错误: length(time(x)) == length(by[[1]]) is not TRUE

转载 作者:行者123 更新时间:2023-12-02 11:12:33 30 4
gpt4 key购买 nike

我正在尝试使用 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("mydata.csv", header=TRUE)

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

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

#create a zoo series with the required variables
PE.data <- mydata[ ,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 函数上工作。

最佳答案

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

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

希望这有帮助。

关于r - 动物园错误: length(time(x)) == length(by[[1]]) is not TRUE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32437990/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com