[R] ploting missing data

Gabor Grothendieck ggrothendieck at gmail.com
Fri Sep 7 17:26:00 CEST 2007


Try this:

library(zoo)
plot(na.approx(zoo(as.matrix(data[-1]), data[,1])), plot.type = "single")

See ?na.approx, ?plot.zoo, ?xyplot.zoo and vignette("zoo")

On 9/7/07, Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de> wrote:
> Hello,
>
> I have this kind of dataframe and have to plot it.
>
> data <- data.frame(sw= c(1,2,3,4,5,6,7,8,9,10,11,12,15),
>    zehn =
> c(33.44,20.67,18.20,18.19,17.89,19.65,20.05,19.87,20.55,22.53,NA,NA,NA),
>     zwanzig =
> c(61.42,NA,26.60,23.28,NA,24.90,24.47,24.53,26.41,28.26,NA,29.80,35.49),
>     fuenfzig =
> c(162.51,66.08,49.55,43.40,NA,37.77,35.53,36.46,37.25,37.66,NA,42.29,47.80)
> )
>
> The plot should have lines:
> lines(fuenfzig~sw, data=data)
> lines(zwanzig~sw, data=data)
>
> But now I have holes in my lines for the missing values (NA). How to
> plot the lines without the holes?
> The missing values should be interpolated or the left and right point
> directly connected. The function approx interpolates the whole dataset.
> Thats not my goal!
> Is there no plotting function to do this directly?
>
> Best
> Markus
>
> --
> Dipl.-Tech. Math. Markus Schmidberger
>
> Ludwig-Maximilians-Universität München
> IBE - Institut für medizinische Informationsverarbeitung,
> Biometrie und Epidemiologie
> Marchioninistr. 15, D-81377 Muenchen
> URL: http://ibe.web.med.uni-muenchen.de
> Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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