[R] Getting Rid of NaN in ts Object

Jim Lemon drjimlemon at gmail.com
Fri May 27 12:46:20 CEST 2016


Hi Lorenzo,
Maybe:

tt<-tt[!is.nan(tt)]

Jim


On Fri, May 27, 2016 at 8:14 PM, Lorenzo Isella
<lorenzo.isella at gmail.com> wrote:
> Dear All,
> I am sure the answer is a one liner, but I am banging my head against
> the wall and googling here and there has not helped much.
> Consider the following time series
>
> tt<-structure(c(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
> NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 1133.09, 1155.77, 1179.12,
> 1182.85, 1133.43, 1103.36, 1081.19, 1058.55, 1056.95, 1059.13,
> 1018.18, 920.62, 865.99, 856.29, 841.58, 857.7, 852.71, 890.76
> ), .Tsp = c(1980, 2015, 1), class = "ts")
>
>
> where the NaN do *not* occur internally. How can I automatically get
> rid of them and adjust the start and end year of the time series
> accordingly?
> Many thanks
>
> Lorenzo
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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