Skip to content

using "for" loop

2 messages · alessandro carletti, Renaud Lancelot

#
Hi everybody,
how can I create a loop for plotting parameters for
each level of a variable, for example:

NAME   temperature  depth
aaa      23           -1
aaa      22           -2
aaa      24           -1
bbb      23           -4
bbb      23           -1 
aaa      22           -1
bbb      22            0

I mean, I would like R to plot temperature vs depth
for aaa, then another plot for bbb, and so on.

Is it for loop ok?
Thanks
#
alessandro carletti a ??crit :
Package lattice is your friend. Using your example:

Data <- read.table(file = "clipboard", header = TRUE)
library(lattice)
xyplot(temperature ~ depth | NAME, data = Data)

Best,

Renaud