stephen sefick
2008-Aug-18 01:55 UTC
[R] Multiple Plotting help (lines don't always connect)
d <- structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, NA, NA, NA, 14), .Dim = c(14L, 2L ), .Dimnames = list(NULL, c("a", "b"))) plot(d, type="b") This is simplified, but Is there an option I am missing that will force all of the points to be joined by a line? Stephen Sefick -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
You have to get rid of the NAs since they indicate that there are no values and will not draw a line:> c.d <- d[complete.cases(d),] > plot(c.d, type='b') >On Sun, Aug 17, 2008 at 6:55 PM, stephen sefick <ssefick at gmail.com> wrote:> d <- structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1, > 2, 3, 4, 5, 6, 7, 8, 9, 10, NA, NA, NA, 14), .Dim = c(14L, 2L > ), .Dimnames = list(NULL, c("a", "b"))) > plot(d, type="b") > > This is simplified, but Is there an option I am missing that will > force all of the points to be joined by a line? > > Stephen Sefick > > > -- > Let's not spend our time and resources thinking about things that are > so little or so large that all they really do for us is puff us up and > make us feel like gods. We are mammals, and have not exhausted the > annoying little problems of being mammals. > > -K. Mullis > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
markleeds at verizon.net
2008-Aug-18 02:06 UTC
[R] Multiple Plotting help (lines don't always connect)
I don't know if it's the best way but you can do d<-d[complete.cases(d),] plot(d, type="b") plot doesn't connect the points when there are NAs between them. On Sun, Aug 17, 2008 at 9:55 PM, stephen sefick wrote:> d <- structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1, > 2, 3, 4, 5, 6, 7, 8, 9, 10, NA, NA, NA, 14), .Dim = c(14L, 2L > ), .Dimnames = list(NULL, c("a", "b"))) > plot(d, type="b") > > This is simplified, but Is there an option I am missing that will > force all of the points to be joined by a line? > > Stephen Sefick > > > -- > Let's not spend our time and resources thinking about things that are > so little or so large that all they really do for us is puff us up and > make us feel like gods. We are mammals, and have not exhausted the > annoying little problems of being mammals. > > -K. Mullis > > ______________________________________________ > 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.
You can also do: plot(approx(d[,1], d[,2], xout=d[,1]), type='b') This will interprete the values between the missing values, but it is probably best to leave it as you first had it with the missing lines so that you know there is something different in the data. On Sun, Aug 17, 2008 at 6:55 PM, stephen sefick <ssefick at gmail.com> wrote:> d <- structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1, > 2, 3, 4, 5, 6, 7, 8, 9, 10, NA, NA, NA, 14), .Dim = c(14L, 2L > ), .Dimnames = list(NULL, c("a", "b"))) > plot(d, type="b") > > This is simplified, but Is there an option I am missing that will > force all of the points to be joined by a line? > > Stephen Sefick > > > -- > Let's not spend our time and resources thinking about things that are > so little or so large that all they really do for us is puff us up and > make us feel like gods. We are mammals, and have not exhausted the > annoying little problems of being mammals. > > -K. Mullis > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Carl Witthoft
2008-Aug-19 21:52 UTC
[R] Multiple Plotting help (lines don't always connect)
Just my view on the lines/interpolate/don't interpolate controversy here: I was taught once upon a time to plot actual data as points (with or without error bars), and plot fitted curves as lines. Only when the density of data points is so high as to make a 'mess' of the chart is it ok to plot a line representing the actual data. YMMV Carl