try to use xyplot of latice package. If you have a data.frame called data, whit coluns called year and x, you could do something like:
require(lattice) xyplot(x~year,data, type = "a", auto.key = list(space = "right", points = FALSE, lines = TRUE)) _______________________ Gledson Luiz Picharski PET EstatÃstica - UFPR http://www.leg.ufpr.br/~gledson <http://www.leg.ufpr.br/%7Egledson> http://www.leg.ufpr.br/pet 2009/1/10 Jim Lemon <j...@bitwrit.com.au> > Kitty Lee wrote: > >> Hi. This may be a straight-forward question... >> >> I have a time series from 1950 to 2000 (by year) with missing values. >> Sometimes only a year has value and the adjacent years have missing data, >> e.g. >> >> 1950 2.7 >> 1951 1952 >> 1953 3.4 >> 1954 >> 1955 >> 1956 2.9 >> 1957 3.6 >> 1958 2.7 >> >> >> When I use plot (type='l'), the line can't connect the 'stand-alone' >> years. Is there a way I have have R to skip over the NA and draw a line with >> the points available? >> >> >> > Hi Kitty, > Assuming that the above is a data frame with two columns, the second of > which is named "value": > > plot(my.data.frame[!is.na(my.data.frame$value),],type="l") > > Jim > > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]]
______________________________________________ R-help@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.