Skip to content
Prev 140102 / 398506 Next

More elegant multiplication or division of a data frame with a vector

Not sure if these are any better but here are a few alternatives:

rawdata / rep(sens, each = nrow(rawdata))

as.data.frame(mapply("/", rawdata, sens))

as.data.frame(as.matrix(rawdata) %*% diag(1/sens))
On Sat, Mar 22, 2008 at 10:21 AM, Tribo Laboy <tribolaboy at gmail.com> wrote: