[R] using lapply and split to plot up subsets of a vector
karmakiller
roisinmoriarty at gmail.com
Thu Dec 30 13:55:54 CET 2010
Hi again,
I have spent the last couple of days trying to build a function that will
allow me to add to the multiple plots that I created with your advice. I
have changed to
plot(ln.o2con~lnbm,data=df)
in my function and this works fine.
On an individual plot I can fit quantile regressions using "quantreg" but I
can't figure out how to plot these lines on the multiple graphs that I can
create with plot.
a<- function(df)abline(rq(ln.o2con~lnbm,tau=0.99,data=df))
b<- lapply(split(one,one$sp.id),a)
print(b)
c<- function(df)abline(rq(ln.o2con~lnbm,tau=0.01,data=df))
d<- lapply(split(one,one$sp.id),c)
print(d)
e<- function(df)abline(rq(ln.o2con~lnbm,tau=0.01,data=df))
f<- lapply(split(one,one$sp.id),e)
print(f)
My knowledge of building functions in R is poor and I can't figure out how
to combine these functions so that I may plot each graph individually with
the correct ablines for each fit. I can get the lines to plot but only on
one graph.
Again I would be grateful for any help, I really like using R but it is the
bottleneck in my analysis and things are moving very slow while I try to
tackle this steep learning curve and become a more familiar with how to use
R the best way.
Thank you
--
View this message in context: http://r.789695.n4.nabble.com/using-lapply-and-split-to-plot-up-subsets-of-a-vector-tp3166634p3168223.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list