0

Similar questions have been raised for all combinations of objects within lists (see here or here), but this particular problem has yet not been asked:

I have two lists that contain the same (high) number of data frames, with the same name, size and ordering, though different values, see this sample data set:

A <- data.frame(matrix(rnorm(30), nrow=5, ncol=6))
B <- data.frame(matrix(rnorm(20), nrow=5, ncol=4))
list1 <- list(A,B)

A <- data.frame(matrix(rnorm(30), nrow=5, ncol=6))
B <- data.frame(matrix(rnorm(20), nrow=5, ncol=4))
list2 <- list(A,B)

I would now like to multiply data frames with the same name element wise and store the result in a new list, such that:

list3: 
A*A B*B

Any advice would be much appreciated!

Sotos
  • 51,121
  • 6
  • 32
  • 66
Luks
  • 133
  • 11
  • 2
    Just `Map('*', list1, list2)` – Sotos Jul 03 '17 at 13:38
  • Thanks, this works. The question has indeed been [anwered](https://stackoverflow.com/questions/25233916/r-multiply-matrixes-in-list) as marked by Imo. However, as title and question of the latter are somewhat blurry / misleading I will leave my question in the system for future reference !? – Luks Jul 03 '17 at 13:50
  • Yes leave it up. It serves as a reference point – Sotos Jul 03 '17 at 13:51

0 Answers0