Select certain rows of data to plot with ggplot

6,039 views
Skip to first unread message

scott smith

unread,
Dec 13, 2011, 11:12:28 AM12/13/11
to ggplot2
Hi,

simple one but I'm stumped...

I have a data set with 100 rows and a header row. I'm trying to plot
data rows 1-20 alone, (and then I'll plot 21-40..etc once this is
sorted)

so I can do it with qplot no problem:

qplot(myo_stress[1:20],sas_stress[1:20])

....but not with ggplot (it still shows all 100 data points):

ggplot(data,aes(myo_stress[1-20],sas_stress[1-20])) + geom_point ()

Any thoughts?
Scott

Brandon Hurr

unread,
Dec 13, 2011, 11:15:53 AM12/13/11
to scott smith, ggplot2
How about:

ggplot(data[1:20,], aes(myo_stress, sas_stress)) + geom_point()

Should work... 

Brandon

Scott

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

scott smith

unread,
Dec 13, 2011, 11:35:37 AM12/13/11
to Brandon Hurr, ggplot2
great - thanks Brandon

Knew it was be something simple!!
Reply all
Reply to author
Forward
0 new messages