Re: [R] using "for" loop

From: Renaud Lancelot <renaud.lancelot_at_cirad.fr>
Date: Fri 05 Aug 2005 - 19:12:48 EST

alessandro carletti a écrit :
> 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

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

-- 
Dr Renaud Lancelot, vétérinaire
Projet FSP régional épidémiologie vétérinaire
C/0 Ambassade de France - SCAC
BP 834 Antananarivo 101 - Madagascar

e-mail: renaud.lancelot@cirad.fr
tel.:   +261 32 40 165 53 (cell)
         +261 20 22 665 36 ext. 225 (work)
         +261 20 22 494 37 (home)

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Aug 05 19:17:24 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:05:29 EST