[R] tis: cannot alter subset when input matrix contains NAs

Gabor Grothendieck ggrothendieck at gmail.com
Fri Apr 30 20:01:33 CEST 2010


Here is a workaround:

for(i in 1:nrow(x)) x[i, x[i, ] > 0] <- 0

On Fri, Apr 30, 2010 at 11:10 AM, Abiel X Reinhart
<abiel.x.reinhart at jpmchase.com> wrote:
> When using the tis time series package (v1.9), I cannot select or alter a subset of a time series when the time series is created from a matrix and the matrix contains NA values.
>
> Example:
>
> x<-tis(t(c(1:10,NA)), start=c(2000,1), freq=12)
> x[x>0]<-0
>
> The second line yields "Error in if (any(i > nrow(x))) { : missing value where TRUE/FALSE needed"
>
> However, both of the following work fine:
>
> x<-tis(t(c(1:10)), start=c(2000,1), freq=12) # Does not contain NA
> x[x>0]<-0
> x<-tis(c(1:10,NA), start=c(2000,1), freq=12) # Contains NA, but input is not a matrix
> x[x>0]<-0
>
> Can someone suggest a solution? Is this a bug? Thanks.
>
> Abiel
>
>
> This communication is for informational purposes only. I...{{dropped:30}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list