[2,] 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
quot; "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 this pro
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,]
3 matches
Mail list logo