Re: [R] multiplication by groups

2016-04-24 Thread Giorgio Garziano
df1 <- data.frame(ID = c(1,1,2,2,3,3,4,4,5,5), A = c(1,0,5,1,1,NA,0,3,2,7), B = c(2,3,NA,3,4,NA,1,0,5,NA)) df2 <- data.frame(ID = c(1,2,3,4,5), A = c(1,6,1,3,9), B = c(5,3,4,1,5)) m <- match(df1$ID, df2$ID) sel <-

[R] multiplication by groups

2016-04-23 Thread Saba Sehrish via R-help
Hi I have two data frames as shown below (second one is obtained by aggregating rows of similar IDs in df1.). They both have similar number of columns but rows of df2 are lesser than rows of df1. df1: IDAB 1 12 1 03 2 5NA