v1 <- c("red", "a","b","c",1, 3, 5, 7) v2 <- c("red", "a","b","c",1, 3, 5, 7) v3 <- c("blue", "a","b","d",2, 4, 6, 8) v4 <- c("blue", "a","b","d",2, 4, 6, 8) v5 <- c("blue", "a","b","d",2, 4, 6, 8) df1 <- data.frame(rbind(v1,v2,v3,v4,v5)) v6 <- c("red", 2,2,4,2) v7 <- c("blue",1,1,0,1) df2 <- data.frame(rbind(v6,v7)) colnames(df2) <- c("Y1", "Y2", "Y3", "Y4", "Y5") > df1 X1 X2 X3 X4 X5 X6 X7 X8 v1 red a b c 1 3 5 7 v2 red a b c 1 3 5 7 v3 blue a b d 2 4 6 8 v4 blue a b d 2 4 6 8 v5 blue a b d 2 4 6 8 > df2 Y1 Y2 Y3 Y4 Y5 v6 red 2 2 4 2 v7 blue 1 1 0 1 How do I take the 4 numeric columns from df2 and multiply them within factor(red, blue) and within column (respectively)? Say I would want to take (v6, X2) and multiply it by (v1:v2,X5).
If you need further clarification of what I am trying to do please ask.
edit: For clarification, I want to make all possible multiplications of above example.
edit2: edited colnames
suffixesin the merge?v1(and other rows) are converted to characters. You end up with a data.frame where each column is a factor...