Skip to content
Prev 247616 / 398503 Next

tips for looping over a category for beginner

Hi,

First a good tip when you ask on the R list is to provide data in a way 
that we can readily use it. I think the best way to do it is to copy the 
output of dput(tc) into the email you write.

There might be better ways to do what you want, but here is what I would do:

#first subset what you need:
tc_clay <- tc[LithClass=="clay",]
#or
tc_not_clay <- tc[LithClass!="clay",]

#you might need to drop the unused levels if you don't want all of them 
to be plotted without values. Two ways (at least) to do it:
tc_clay <- factor(tc_clay)
tc_not_clay <- droplevels(tc_not_clay)

#then you can plot
plot(tc_clay$Conductivity~tc_clay$Depth)
boxplot(tc_not_clay$Conductivity~tc_not_clay$LithClass)

I hope it will help you get started.
Ivan

Le 1/18/2011 07:48, Ben Harrison a ?crit :