Hi David,
1) Thanks very much. Your code shows that this was much simpler than I
anticipated.
2) I have made the appropriate changes to email in plain text. My apologies.
Thanks!
Dan
On Wed, Oct 30, 2013 at 1:17 PM, David Winsemius wrote:
>
> On Oct 30, 2013, at 4:07 AM, Dan Abner wrote:
>
>
On Oct 30, 2013, at 4:07 AM, Dan Abner wrote:
> Hi everybody,
>
> I have data in the format of the example data below where essentially a
> large number of indicator variables (coded [0,1]) reflect traits of the
> same id across multiple rows. I need to represent the data in a 1 row per
> id for
..@r-project.org] On Behalf Of Dan Abner
Sent: Wednesday, October 30, 2013 7:24 AM
To: Rui Barradas
Cc: r-help@r-project.org
Subject: Re: [R] Subtotals by id for a large number of columns
Hi Rui,
Thanks for responding. When I make this change, I get an error
message:
> mysum<-function(x
Hi,
May be:
apply(d1[3:5],2, mysum)
var1 var2 var3
1 2 0 1
2 2 2 3
3 1 1 1
4 0 1 0
#or
sapply(d1[3:5],mysum)
#or
library(plyr)
ddply(d1[,-2],.(id),colwise(sum))
A.K.
On Wednesday, October 30, 2013 8:30 AM, Dan Abner wrote:
Hi Rui,
Thanks for responding.
Hi Rui,
Thanks for responding. When I make this change, I get an error message:
> mysum<-function(x) tapply(x,d1$id,sum)
>
> d2<-apply(d1[2:4],mysum)
Error in match.fun(FUN) : argument "FUN" is missing, with no default
Thoughts?
On Wed, Oct 30, 2013 at 8:01 AM, Rui Barradas wrote:
> Hello,
>
Hello,
If I understand it correctly, just change mysum to the following.
mysum<-function(x) tapply(x,d1$id,sum)
Hope this helps,
Rui Barradas
Em 30-10-2013 11:07, Dan Abner escreveu:
Hi everybody,
I have data in the format of the example data below where essentially a
large number of indi
Hi everybody,
I have data in the format of the example data below where essentially a
large number of indicator variables (coded [0,1]) reflect traits of the
same id across multiple rows. I need to represent the data in a 1 row per
id format. I see this as being similar to converting from long to
7 matches
Mail list logo