Re: [R] Counts of duplicate rows as a new column without grouping of duplicates raws.

2013-12-26 Thread arun
Also, you could try: library(plyr) ddply(dat1,.(A),mutate, D=length(A)) #or library(data.table)  dt1 <- data.table(dat1,key='A')  dt1[,D:=.N,by='A'] A.K. On , arun wrote: Hi, Try: dat1 <- read.table(text="A    B    C 1 a    1    ff 2 b    1    re 3 c    1    sd 5 a    2    as 6 c    4    fe 7

Re: [R] Counts of duplicate rows as a new column without grouping of duplicates raws.

2013-12-26 Thread arun
Hi, Try: dat1 <- read.table(text="A    B    C 1 a    1    ff 2 b    1    re 3 c    1    sd 5 a    2    as 6 c    4    fe 7 d    5  tt 8 d    5  tt 9 d    9  oi",sep="",header=TRUE,stringsAsFactors=FALSE)  within(dat1,D<-ave(seq_along(A),A,FUN=length)) A.K. On Thursday, December 26,

[R] Counts of duplicate rows as a new column without grouping of duplicates raws.

2013-12-26 Thread Bartłomiej Taciak
Hi everyone, My data looks like this one: AB C 1 a 1 ff 2 b 1 re 3 c 1 sd 5 a 2 as 6 c 4 fe 7 d 5 tt 8 d 5 tt 9 d 9 oi I want to add a new column D, which will contain how many an element from the column A is repeated,