Dear Jorge,

I already try this solution. But I need to retrieve the information in 
function of var3 and not var2, but excluding repeated measure in var2.

> tapply(test$var2,test$var3,length)
a1 b1 c1 d1 
 3  1  1  1 

but in a1 I need the result=2 and not 3 because two elements in var2 are 
repeated

Thanks
Ronaldo

Em Ter 01 Set 2009, Jorge Ivan Velez escreveu:
> Dear Ronaldo,
> You were almost there!  Here is a suggestion:
>
>  with(test, tapply(var3, var2, length))
> # a b c d e
> # 2 1 1 1 1
>
> HTH,
> Jorge
>
>
> 2009/9/1 Ronaldo Reis Júnior <>
>
> > Hi,
> >
> > this is a simple question
> >
> > I have this data.frame:
> > > test <-
> >
> > data.frame(var1=c(1,1,1,1,1,1),var2=c("a","a","b","c","d","e"),var3=c("a1
> >","a1","b1","a1","c1","d1"))
> >
> > > test
> >
> >  var1 var2 var3
> > 1    1    a   a1
> > 2    1    a   a1
> > 3    1    b   b1
> > 4    1    c   a1
> > 5    1    d   c1
> > 6    1    e   d1
> >
> > Then I need to calculate the number of var3 excluding the repeated
> > measure of
> > var2.
> >
> > With tapply I have this:
> > > tapply(test$var1,test$var3,sum)
> >
> > a1 b1 c1 d1
> >  3  1  1  1
> >
> > But the correct result is:
> >
> > a1 b1 c1 d1
> >  2  1  1  1
> >
> > because on factor "a1" in var3 I have 2 repeated factor "a" in var2.
> >
> > I try a simple solution for it but without success. aggregate function
> > dont work with factors (var3 by var1).
> >
> > Anybody have an idea?
> >
> > Thanks
> > Ronaldo
> > --
> > "It's men like him that give the Y chromosome a bad name."
> > --
> >
> > > Prof. Ronaldo Reis Júnior
> > >
> > |  .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
> > |
> > | : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
> > |
> > | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
> > |   `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br |
> >
> > chrys...@gmail.com
> >
> > | http://www.ppgcb.unimontes.br/lecc | ICQ#: 5692561 | LinuxUser#: 205366
> >
> > --
> > Favor NÃO ENVIAR arquivos do Word ou Powerpoint
> > Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF.
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
-- 
Pe�o paci�ncia aos impacientes que desejam meu desaparecimento: j�
est� faltando menos que antes.
                -- Jacinto Benavente
--
> Prof. Ronaldo Reis Júnior
|  .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
| : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
|   `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br | chrys...@gmail.com
| http://www.ppgcb.unimontes.br/lecc | ICQ#: 5692561 | LinuxUser#: 205366
--
Favor NÃO ENVIAR arquivos do Word ou Powerpoint
Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to