[R] plotting time series with data gap using type line- but do not want to connect gap with line
Gabor Grothendieck
ggrothendieck at gmail.com
Thu May 28 21:16:42 CEST 2009
Just place a point with an NA value between the two segments.
Here is one way to do it in zoo:
set.seed(123)
library(zoo)
# create sample data
tt <- c(1:1000, 1200:2000)
z <- zoo(rnorm(length(tt)), tt)
# this will fill in omitted values with NAs
z <- as.zoo(as.ts(z))
plot(z)
On Thu, May 28, 2009 at 3:05 PM, <Josef.Kardos at phila.gov> wrote:
> I have a time series of about 1500 measurements. There are sporadic data
> gaps. I would like to plot the time series with type "line". I only want
> a line to connect the periods with data; I don't want a line to connect
> the points across a data gap. Is there a function or recommended method
> to deal with this?
>
> For example
> there are 2000 days
> days 1:1000 each have one measurement of temperature
> days 1001: 1199 have no data
> days 1200:2000 each have one measurement of temperature
>
> I want the plot to connect points 1:1000 with a line, and to connect
> points 1200: 2000 with a different line. I don't want a line to connect
> points 1001:1200.
>
> I searched the help archives and google but couldn't find anything. Any
> advice?
>
>
>
> JK
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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