Try this (adding 0 converts the logicals to numeric):
rowsum((X > 0)+0, group)
On Jan 26, 2008 9:13 AM, Anders Bjørgesæter <[EMAIL PROTECTED]> wrote:
> Hello
>
> Is there an analogous function to "rowsum" that count the numbers
> according to a given vector (preferably larger than a given value)
Is this what you are looking for in doing computations on the columns
of a dataframe?
> x <-
> data.frame(group=sample(1:2,10,TRUE),A=sample(1:4,10,TRUE),B=sample(1:5,10,TRUE),
+ C=sample(1:3,10,TRUE))
> x
group A B C
1 1 2 4 1
2 2 4 1 2
3 1 3 2 1
4 2 3 2 2
5 2 4 2
Hello
Is there an analogous function to ”rowsum” that count the numbers
according to a given vector (preferably larger than a given value)
instead of summing them?
E.g. rowsum(x, group)
X is the dataframe, A B C
5 0 0
3 matches
Mail list logo