[R] Error in if (x[j, g] == x[i, g]) { : missing value where TRUE/FALSE needed
David Winsemius
dwinsemius at comcast.net
Thu Mar 17 21:53:01 CET 2016
> On Mar 17, 2016, at 8:22 AM, Chattopadhyay, Somsubhra <sch298 at g.uky.edu> wrote:
>
> I am using the "hydroTSM" package and "trend" package to convert my daily
> time series into monthly and then analyze the seasonal trend. My code is
>
> y <-read.csv("P-GHCNDUSW00093820.csv",as.is=TRUE)
> y$DATE <- as.Date(as.character(y$DATE),format="%Y%m%d")
> x <- xts(y$PRCP,y$DATE)
> p <- daily2monthly(x, FUN=sum, na.rm = T)
> r <- as.ts(p)
> SeasonalMannKendall(r)
>
> The last line returns an error like
> Error in if (x[j, g] == x[i, g]) { :
> missing value where TRUE/FALSE needed
After each line of code you should be examining the results of `str` applied to the results to see if you are actually succeeding. And given the error message you might consider looking at:
sum( is.na( y$DATE))
>
> I suspect that the error is because of the format of the time series object
> which may not be correct as in the attached image.
No image attached. Read the info page and the posting guide again.
> It is making the monthly
> sums correct however I don't know why there are so many NA values. Each
> year should have only 12 values for the 12 months.
>
> Any ideas how to fix this error?
>
>
> --
> *Somsubhra Chattopadhyay*
--
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list