I have the following matrix:
m <- as.matrix(data.frame(a = c(-1,2,3,4),
b = c(-1,2,2,-4),
c = c(-1,3,1,-2)))
I want to multiply every column with the corresponding value in vector v which is the same length as the number of columns in m. I want to only apply the multiplication to the positive values in that column.
v <- c(2,3,-3)
such that column a becomes (-1,4,6,8)
My dataset is large, so I'm looking for an elegant solution