Thanks. ave() is the exact function I was after.
tonyxv wrote:
>
> Hello,
> I have a dataframe
>
>
> ID1 ID2
> A1B3
> A1B4
> A1B3
> A1B3
> A2B1
> A2B1
> A2B4
> A3B2
> A3B2
> A5B1
> A5B1
> A5B6
> A5B4
> A6B2
>
>
>
> I want to add e
This should do it for you:
> x <- read.table(textConnection("ID1 ID2
+ A1B3
+ A1B4
+ A1B3
+ A1B3
+ A2B1
+ A2B1
+ A2B4
+ A3B2
+ A3B2
+ A5B1
+ A5B1
+ A5B6
+ A5B4
+ A6B2"), header=TRUE)
> cbind(x, countID1=ave(seq_along(x$ID1), x$ID1, FUN=leng
Hello,
I have a dataframe
ID1 ID2
A1B3
A1B4
A1B3
A1B3
A2B1
A2B1
A2B4
A3B2
A3B2
A5B1
A5B1
A5B6
A5B4
A6B2
I want to add extra columns to the dataframe CountID1 and CountID2 which is
the actual count of values such as A1 etc
ie
ID1
3 matches
Mail list logo