Jim,
You're going to want to do something like this:
plotdata <- merge( a, b, by=1, all=T )
library( reshape )
plotdata_melted <- melt(plotdata,id.vars=1)
library( ggplot2 )
qplot( position, value, data=plotdata_melted, geom="line", color=variable )
Regards,
Ben
On Mon, Sep 24, 2012 at 6:29 PM, Jim mikeself <
jimmi...@gmail.com> wrote:
> Hello,
> I just start to learn R and ggplot2. Can someone help?
> Thanks,
>
> I have two data sets. Using position as X, and count as Y, how can I plot
> them out as two diffrent colorful lines in a single plot using ggplot2
> geom_line?
>
> dataset a:
> position count
> 1 3
> 2 9
> 3 10
> 4 15
> 5 19
> 6 28
> 7 15
> 8 13
> 9 11
> 18 5
>
> dataset b:
> position count
> 1 8
> 2 4
> 3 16
> 4 17
> 5 19
> 6 10
>
> Thanks a lot!
>
> Jim
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
>
https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email
ggp...@googlegroups.com
> To unsubscribe: email
ggplot2+u...@googlegroups.com
> More options:
http://groups.google.com/group/ggplot2