Dear Friends, My objective is to do element wise multiplication of two vectors. For example suppose I have
a <- (1,1,1) b <- (2,4) My output should be (2,4,2,4,2,4). I managed to write it down with loops as follows r <- c(1,1,1) l <- c(2,4) x <- 1 for (j in 1:3) { for (i in 1:2) { new[x,] <- r[j]*l[i] x <- x+1 } } Is there a simpler solution to this without using the loops? Thanks and Regards Anup --------------------------------- Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.