[R] list multiplied by a factor / mapply

Patrick Hausmann patrick.hausmann at uni-bremen.de
Wed Feb 23 10:11:11 CET 2011


Dear list,

this works fine:

x <- split(iris, iris$Species)
x1 <- lapply(x, function(L) transform(L, g = L[,1:4] * 3))

but I would like to multiply each Species with another factor:
setosa by 2, versicolor by 3 and virginica by 4. I've tried mapply but 
without success.

Any thoughts? Thanks for any idea!
Patrick



More information about the R-help mailing list