> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Ronaldo Reis Júnior
> Sent: Tuesday, September 01, 2009 4:43 PM
> To: R-Help
> Subject: Re: [R] Simple question about data.frame reduction
>
> Dear Jorge,
Sorry, my bad. Here is a suggestion to do what you asked for in your post:
with(test, tapply(var2, var3, function(x) length(unique(x
# a1 b1 c1 d1
# 2 1 1 1
HTH,
Jorge
2009/9/1 Ronaldo Reis Júnior
> Dear Jorge,
>
> I already try this solution. But I need to retrieve the information in
Hi,
I find a simple solution:
aggregate(test$var2,list(test$var3,test$var2),length)
Group.1 Group.2 x
1 a1 a 2
2 b1 b 1
3 a1 c 1
4 c1 d 1
5 d1 e 1
Thanks
Ronaldo
Em Ter 01 Set 2009, Ronaldo Reis Júnior escreveu:
> Dear Jorge,
>
> I alre
Try this:
> with(unique(d), tapply(var1, var3, sum))
a1 b1 c1 d1
2 1 1 1
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
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
repe
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"
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
11a a1
21a a1
31b b1
41c a1
51d c1
61e d1
Th
7 matches
Mail list logo