Skip to content
Prev 167402 / 398503 Next

Multiplication of dataframes

you should first transform them to matrices using data.matrix() and then 
do a matrix multiplication using %*%.

This will create a matrix, which you can then convert to a data frame, 
if you want, using as.data.frame(). For instance, check the following:

d1 <- data.frame(x = rnorm(10), y = rnorm(10))
d2 <- data.frame(x = rnorm(10), y = rnorm(10))

res <- data.matrix(d1) %*% t(data.matrix(d2))
res
as.data.frame(res)


I hope it helps.

Best,
Dimitris
glenn wrote: