David Doyle
2012-Apr-24 03:26 UTC
[R] Scatter plot / LOESS, or LOWESS for more than one parameter
Hi folks. If I have the following in my "data" event pH1 pH2 1 4.0 6.0 2 4.3 5.9 3 4.1 6.1 4 4.0 5.9 and on and on..... for about 400 events Is there a way I can get R to plot event vs. pH1 and event vs. pH2 and then do a loess or lowess line for each?? Thanks in advance David [[alternative HTML version deleted]]
R. Michael Weylandt
2012-Apr-24 04:40 UTC
[R] Scatter plot / LOESS, or LOWESS for more than one parameter
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:> Hi folks. > > If I have the following in my "data" > > event ? ?pH1 ? ?pH2 > 1 ? ? ? ? ? ?4.0 ? ? 6.0 > 2 ? ? ? ? ? ?4.3 ? ? 5.9 > 3 ? ? ? ? ? ?4.1 ? ? 6.1 > 4 ? ? ? ? ? ?4.0 ? ? 5.9 > and on and on..... for about 400 events > > Is there a way I can get R to plot event vs. pH1 ?and event vs. pH2 and > then do a loess or lowess line for each?? > > Thanks in advance > David > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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.