Re: [R] plot

From: Ted Harding <Ted.Harding_at_nessie.mcc.ac.uk>
Date: Fri 09 Dec 2005 - 23:24:27 EST


On 09-Dec-05 Rhett Eckstein wrote:
> Dear R users:
>

>> C1

> time X1
> 1 0.5 6.296625
> 2 1.0 10.283977
> 3 1.5 12.718610
> 4 2.0 14.112740
> 5 3.0 15.053917
> 6 4.0 14.739725
> 7 6.0 12.912230
> 8 8.0 10.893264
> 9 0.5 6.289166
> 10 1.0 10.251247
> 11 1.5 12.651346
> 12 2.0 14.006958
> 13 3.0 14.870618
> 14 4.0 14.487026
> 15 6.0 12.555566
> 16 8.0 10.474695
>> plot(C1,type="l")

> In the plot, there is a straight line between time=0.5 and time=8,
> If I do not want the straight line, what should I do?
> Thanks for any help!!

This happens because 'plot' is based on plotting the entire series of points which you give it, whereas your data (on the basis of the 'time' variable) consists of 2 series.

So the solution is to plit it:

  plot(C1[(1:8),],type="l",col="green")
  lines(C1[(9:16),],col="blue")

(where I've added the "col" option to illustrate how to identify the two series by colour).

Best wishes,
Ted.



E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861
Date: 09-Dec-05                                       Time: 12:24:23
------------------------------ XFMail ------------------------------

______________________________________________
R-help@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 Received on Fri Dec 09 23:29:18 2005

This archive was generated by hypermail 2.1.8 : Sat 10 Dec 2005 - 02:25:52 EST