错误与“;“极端”;R中的包:无法打印返回期
我使用R中的极值包绘制重现期。 但是,我的数据集缺少值,因此我遇到许多错误: 以下是数据: 抱歉,重现期图需要大量的观测点,所以这是我能发布的最小数据集 以下是目前为止的脚本:错误与“;“极端”;R中的包:无法打印返回期,r,R,我使用R中的极值包绘制重现期。 但是,我的数据集缺少值,因此我遇到许多错误: 以下是数据: 抱歉,重现期图需要大量的观测点,所以这是我能发布的最小数据集 以下是目前为止的脚本: library(extRemes) dat<-read.csv("Lumbia_1979-2017.csv",header=T) dat[dat==-999]<-NA #Extract annual max precip annmax <- aggregate(dat$Rain, by = list
library(extRemes)
dat<-read.csv("Lumbia_1979-2017.csv",header=T)
dat[dat==-999]<-NA
#Extract annual max precip
annmax <- aggregate(dat$Rain, by = list(dat$Year),max, na.rm=TRUE,na.action=NULL)
gevfit1 <- fevd(annmax[ ,2])
gevfit1
库(极端)
dat您得到的错误来自聚合
调用:
annmax <- aggregate(dat$Rain, by = list(dat$Year),max, na.rm=TRUE,na.action=NULL)
# Warning messages:
# 1: In FUN(X[[i]], ...) : no non-missing arguments to max; returning -Inf
# 2: In FUN(X[[i]], ...) : no non-missing arguments to max; returning -Inf
# [...]
在这些年中,当aggregate
返回-Inf
时,您没有雨水数据:
dat[dat$Year %in% 2014:2017,]
# Year Month Day Rain
# 1086 2014 1 1 NA
# 1087 2014 1 2 NA
# 1088 2014 1 3 NA
# 1089 2014 1 4 NA
# 1090 2014 1 5 NA
# 1091 2014 1 6 NA
# 1092 2014 1 7 NA
# 1093 2014 1 8 NA
# 1094 2014 1 9 NA
# 1095 2014 1 10 NA
# 1096 2014 1 11 NA
# [...]
所以,这取决于你决定如何处理这些失去的岁月。这取决于分析。分析是否需要缺失年份的数据
1) 如果分析(fevd
)需要缺失年份中的一些数据,则需要一些方法从其他年份中插入这些数据
2) 如果分析不需要缺少的年份,只需删除它们。这是最简单的解决方案:
annmax2 <- annmax[is.finite(annmax[,2]),]
gevfit1 <- fevd(annmax2[ ,2])
annmax2
annmax2 <- annmax[is.finite(annmax[,2]),]
gevfit1 <- fevd(annmax2[ ,2])