[R] R not ploting lines in the correct order
Sarah Goslee
sarah.goslee at gmail.com
Fri Sep 27 15:36:02 CEST 2013
If you use dput() correctly, those of us following along via email can
create an exact duplicate of your R object. All you need to do is:
dput(X)
and paste the resulting output into email.
You see, if I look at your object as you pasted it in, I can't tell if
your Date column is a date format, or character, or factor, or who
knows what, and that may matter for answering your question.
Also, what are "the wrong points"? What points do you expect to be connected?
Sarah
On Fri, Sep 27, 2013 at 8:13 AM, Shane Carey <careyshan at gmail.com> wrote:
> Hi Sarah,
>
> thanks for your reply. Im not sure how to use dput? If I create an object of
> my data, does that mean you can read it in from your side or something?
>
> Here is my code:
> X
> Data Date
> 5.61 24/09/2012 09:13
> 5.80 16/10/2012 11:17
> 6.01 24/10/2012 21:43
> 5.65 11/09/2012 18:34
> 5.27 22/08/2012 15:45
> 5.67 10/08/2012 00:30
> 5.66 14/08/2012 14:52
> 5.81 24/09/2012 12:19
> 5.67 25/10/2012 12:45
> 5.46 07/11/2012 14:07
> 5.81 17/10/2012 10:51
> 5.86 07/11/2012 15:54
> 5.70 01/11/2012 19:21
> 5.33 01/11/2012 12:23
> 5.99 02/10/2012 21:25
> 5.70 30/11/2012 11:40
> 6.06 26/10/2012 13:21
> 5.47 23/08/2012 13:28
> 6.42 19/12/2012 10:54
> 6.05 09/08/2012 22:45
> 5.49 12/09/2012 09:39
> 5.45 11/10/2012 11:28
> 5.48 13/08/2012 16:15
> 5.61 10/09/2012 11:01
> 5.96 21/08/2012 10:55
> 5.37 30/11/2012 10:03
> 5.77 26/10/2012 17:08
> 5.81 03/10/2012 12:45
> dput(X, "X")
> plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> lines(X$Data,Y$Date,pch=21, col="blue",type="o")
>
>
> Thanks again
>
>
> On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee <sarah.goslee at gmail.com>
> wrote:
>>
>> Hi Shane,
>>
>> Please use dput() to provide your data, rather than pasting it in so
>> that we can work from the same R object you are. Please also provide
>> the code you're using to make the graph.
>>
>> Sarah
>>
>> On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey <careyshan at gmail.com> wrote:
>> > Hi,
>> >
>> > I have a set of x, y points where x represents dates and y actual
>> > values. I
>> > am trying to plot a line graph of the data with points on top, but R is
>> > connecting the wrong points with lines. Does anyone know how I can
>> > rectify
>> > this. Please see sample below:
>> >
>> > x=
>> > 24/09/2009 09:13 16/10/2009 11:17 24/10/2009 21:43 11/09/2009
>> > 18:34 22/08/2009
>> > 15:45 10/08/2009 00:30 14/08/2009 14:52 24/09/2009 12:19
>> > 25/10/2009 12:45 07/11/2009 14:07 17/10/2009 10:51 07/11/2009 15:54
>> > 01/11/2009 19:21 01/11/2009 12:23 02/10/2009 21:25 30/11/2009 11:40
>> > 26/10/2009 13:21 23/08/2009 13:28 19/12/2009 10:54 09/08/2009 22:45
>> > 12/09/2009
>> > 09:39 11/10/2009 11:28 13/08/2009 16:15 10/09/2009 11:01 21/08/2009
>> > 10:55 30/11/2009 10:03 26/10/2009 17:08 03/10/2009 12:45
>> >
>> > y=
>> > 4.2537264 4.397792 4.5570224 4.284056 3.9959248 4.2992208
>> > 4.2916384
>> > 4.4053744 4.2992208 4.1399904 4.4053744 4.4432864 4.321968
>> > 4.0414192
>> > 4.5418576 4.321968 4.5949344 4.1475728 4.8679008 4.587352
>> > 4.1627376
>> > 4.132408 4.1551552 4.2537264 4.5191104 4.0717488 4.3750448
>> > 4.4053744
>> > Thanks
>> > --
>> > Shane
>> >
>>
>> --
>> Sarah Goslee
>> http://www.functionaldiversity.org
>
>
>
>
> --
> Shane
More information about the R-help
mailing list