Re: [R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Giovanni Petris
Hi Daniela, There may be other more elegant ways of doing it, but here is one: > myD <- data.frame(code = sample(3, 10, rep = T), prev = rnorm(10), Pr_mean = > 0) > myD codeprev Pr_mean 1 3 -0.06710968 0 2 2 -1.43422034 0 3 1 0.22717580 0 4 3 0.32

Re: [R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Jorge Ivan Velez
Dear Daniela, Try this: set.seed(123) myD<-data.frame(code=sample(letters[1:5],200,replace=T),value=rnorm(200)) tapply(myD$value,myD$code,mean) a b c d e 0.04401465 0.07813648 0.07018791 -0.14508544 -0.02369875 See ?tapply for more information

Re: [R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Rashid Nassar
Would ave() do what you want? Rashid On Tue, 8 Jul 2008, Daniela Ottaviani wrote: > Dear All, > > I have a database of 200 observations named myD. > In the dataframe there are a column named code (with codes varying from 1 to > 77), a column named "prevalence" with some quantitative measur

[R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Gustaf Rydevik
On Tue, Jul 8, 2008 at 3:18 PM, Daniela Ottaviani <[EMAIL PROTECTED]> wrote: > Dear All, > > I have a database of 200 observations named myD. > In the dataframe there are a column named code (with codes varying from 1 to > 77), a column named "prevalence" with some quantitative measurements are >

Re: [R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Ted Harding
On 08-Jul-08 13:18:13, Daniela Ottaviani wrote: > Dear All, > I have a database of 200 observations named myD. > In the dataframe there are a column named code (with codes varying > from 1 to 77), a column named "prevalence" with some quantitative > measurements are given and an column named Pr_mea

Re: [R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Greg Snow
[mailto:[EMAIL PROTECTED] On Behalf Of Daniela Ottaviani > Sent: Tuesday, July 08, 2008 7:18 AM > To: r-help@r-project.org > Subject: [R] Question: Beginner stuck in a R cycle > > Dear All, > > I have a database of 200 observations named myD. > In the dataframe there are a column

[R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Daniela Ottaviani
Dear All, I have a database of 200 observations named myD. In the dataframe there are a column named code (with codes varying from 1 to 77), a column named "prevalence" with some quantitative measurements are given and an column named Pr_mean, with no values. I would like to set a cycle to comp