[R] ggplot: connect points with line (not in order)

billy am wickedpuppy at gmail.com
Sun Apr 5 15:15:37 CEST 2015


Will this do?

ggplot(mydat,aes(xx,yy)) + geom_path()

>From : http://stackoverflow.com/questions/15706281/controlling-order-of-points-in-ggplot2-in-r


----------------------------------------------------------------------------------
|

http://billyam.com  || http://use-r.com  || http://shinyserver.com (BETA)

SAS Certified Base Programmer for SAS 9
Oracle SQL Expert(11g)



On Sun, Apr 5, 2015 at 9:03 PM, Brian Smith <bsmith030465 at gmail.com> wrote:
> Hi,
>
> I am trying to connect points, but not in a different order than the
> default value in ggplot. For example:
>
>  xx <- sample(1:100,5)
>   yy <- sample(1:100,5)
>
>   mydat <- data.frame(xx,yy)
>   print(mydat)
>
>   ggplot(mydat,aes(xx,yy)) + geom_point() + geom_line()
>
>
> I want to connect the points as they appear in mydat, and not necessarily
> from the smallest value on the 'x' axis to the largest.
>
> How can I do this?
>
> thanks!
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list