Re: [R] list multiplied by a factor / mapply

2011-02-23 Thread Henrique Dallazuanna
Try this: x1 <- transform(iris, g = iris[-ncol(iris)] * (as.numeric(iris$Species) + 1 )) On Wed, Feb 23, 2011 at 6:11 AM, Patrick Hausmann < patrick.hausm...@uni-bremen.de> wrote: > Dear list, > > this works fine: > > x <- split(iris, iris$Species) > x1 <- lapply(x, function(L) transform(L, g =

Re: [R] list multiplied by a factor / mapply

2011-02-23 Thread David Winsemius
On Feb 23, 2011, at 4:11 AM, Patrick Hausmann wrote: 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: You will probably confuse yourself by not adopting R ter

[R] list multiplied by a factor / mapply

2011-02-23 Thread Patrick Hausmann
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 fo