Data frame multiplication
Post date: Mar 31, 2014 9:05:50 PM
This is a simple data frame multiplication. Just remember, you can multiply the entry-level when the data frames have the same dimension.
X <- data.frame('a'=c(1,2,3),'b'=c(1,0,1),'c'=c(0,0,1),'d'=c(3,5,6)) Z <- data.frame('az'=c(1,1,1),'bz'=c(1,1,1),'cz'=c(1,1,1),'dz'=c(2,2,2)) Y <- data.frame('ay'=c(1,1,1),'by'=c(0,0,1),'cy'=c(1,1,1),'dy'=c(0,0,1)) W <- data.frame('ay'=c(1,0,1),'by'=c(1,0,1),'cy'=c(1,1,1),'dy'=c(1,0,1)) S <- data.frame('ay'=c(1,1,0),'by'=c(1,0,0),'cy'=c(1,1,1),'dy'=c(0,0,1)) X*Z*Y # > X*Z*Y # a b c d # 1 1 0 0 0 # 2 2 0 0 0 # 3 3 1 1 12 S*(Y | W) # > S*(Y | W) # ay by cy dy # 1 1 1 1 0 # 2 1 0 1 0 # 3 0 0 1 1
Created by Pretty R at inside-R.org
----------