tags:

views:

58

answers:

0

Hello - For ggplot line charts I would like to control when geom_line connects between two points, and when not (due to missing observations). In other words, I would like to be able to tell geom_line to still connect when e.g. one data point is missing, but not when more than one data point is missing. Or to tell it not to connect when an observation is missing. At the moment I can't explain why it connects in some cases and why not in others. Using the code below -- gaps of 5 or more data points are sometimes connected, whereas gaps of 2 or 3 sometimes not. (Sorry, not enough reputation points to attach the charts.) Is there a parameter which can be used? Thanks very much for any advice!

  p <-  (ggplot(df, aes(x=Year, y=value, group=variable, colour=variable))
 + geom_point() + geom_line()
 + facet_wrap(DataType+RatioGroup ~ Gender, ncol = 3)
 + labs(x="Year", y="Ratios of mean income between skill groups", colour="Ratios")
 + scale_x_discrete(labels= c("1970"="70", "1973"="73", "1976"="76", "1979"="79", "1982"="82", "1985"="85", "1988"="88", "1991"="91", "1994"="94", "1997"="97",  "2000"="00", "2003"="03", "2006"="06", "2009"="09"))
 +opts(axis.text.x=theme_text(size=12))
 +opts(axis.text.y=theme_text(size=12)))