Skip to content

Scatter plot / LOESS, or LOWESS for more than one parameter

8 messages · R. Michael Weylandt, Greg Snow, David Doyle

#
The scatter plot is easy:

plot(pH1 ~ pH2, data = OBJ)

When you say a loess for each -- how do you break them up? Are there
repeat values for pH1? If so, this might be hard to do in base
graphics, but ggplot2 would make it easy:

library(ggplot2)
ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
facet_wrap(~factor(pH1))

or something similar.

Michael
On Mon, Apr 23, 2012 at 11:26 PM, David Doyle <kydaviddoyle at gmail.com> wrote:
#
Assuming that you want event as the x-axis (horizontal) you can do
something like (untested without reproducible data):

par(mfrow=c(2,1))
scatter.smooth( event, pH1 )
scatter.smooth( event, pH2 )

or

plot( event, pH1, ylim=range(pH1,pH2) , col='blue')
points( event, pH2, col='green' )
lines( loess.smooth(event,pH1), col='blue')
lines( loess.smooth(event,pH2), col='green')

Only do the second one if pH1 and pH2 are measured on the same scale
in a way that the comparison and any crossings are meaningful or if
there is enough separation (but not too much) that there is no
overlap, but still enough detail.



On Mon, Apr 23, 2012 at 10:40 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:

  
    
1 day later
#
You can also use range( MC.pH, MV.pH, na.rm=TRUE).
On Tue, Apr 24, 2012 at 1:29 PM, David Doyle <kydaviddoyle at gmail.com> wrote:

  
    
5 days later