Re: [R] Multiplying each row of data.frame by a row in another data.frame

2022-04-10 Thread maithili_shiva--- via R-help
  20  20  150 [3,] 300 100 2000 > class(sapply(orig, `*`, vec)) [1] "matrix" "array" Again, there are an amazing number of ways to do anything in R. -Original Message- From: Kelly Thompson Cc: r-help@r-project.org Sent: Sat, Apr 9, 2022 12:49 pm Subject: Re: [R]

Re: [R] Multiplying each row of data.frame by a row in another data.frame

2022-04-09 Thread Avi Gross via R-help
"matrix" "array" Again, there are an amazing number of ways to do anything in R. -Original Message- From: Kelly Thompson Cc: r-help@r-project.org Sent: Sat, Apr 9, 2022 12:49 pm Subject: Re: [R] Multiplying each row of data.frame by a row in another data.frame Does

Re: [R] Multiplying each row of data.frame by a row in another data.frame

2022-04-09 Thread Eric Berger
This looks like homework, which is not permitted on this list. But giving you the benefit of the doubt, here are two ways to do it > as.matrix(val_df) * matrix(rep(weights$value,5),ncol=3,byrow = TRUE) ABC DEF ONS [1,] 10 2 500 [2,] 20 4 500 [3,] 10 20 1000 [4,] 10 4 500 [5,]