Thank you very much, in fact this is different of what I want, because when I use
lapply(seq(ncol(o1)), function(s) o1[, s] * o2) I will obtain products of the columns of o1 by columns of o2, and I want by rows. Anyway thank you very much for your help. Carla 2011/6/14 djmuseR [via R] <[email protected]> > Hi: > > Here's a slightly different approach: > > # Create two numeric matrices with outer(): > o1 <- outer(u,u,">=") * 1L > o2 <- outer(v, v, ">=") * 1L > > # Make a list of matrices that multiplies column i of o1 > # vs. each column of o2 - use the * operator to do this > # Shows what is going on at each step: > lapply(seq(ncol(o1)), function(s) o1[, s] * o2) > > # Concatenate all product columns together into a matrix: > do.call(cbind, lapply(seq(ncol(o1)), function(s) o1[, s] * o2)) > > HTH, > Dennis > > On Mon, Jun 13, 2011 at 6:23 AM, carla moreira <[hidden > email]<http://user/SendEmail.jtp?type=node&node=3595203&i=0>> > wrote: > > > > > u<-c(0.1,0.2,0.3) > > v<-c(0.2,0.3,0.5) > > > > outer1<-outer(u,u,">=") > > outer2<-outer(v,v,">=") > > m<-nrow(outer1) > > j<-nrow(outer2) > > zz<-lapply(1:m, function(m) as.numeric(outer1[m,])) > > tt<-lapply(1:m, function(m) as.numeric(outer2[m,])) > > > > zz[[1]]*tt[[3]], e.g., is possible, but I want every products between two > > > lists. > > > > Is there a way to do that? > > > > -- > > View this message in context: > http://r.789695.n4.nabble.com/How-to-calculate-the-product-of-every-two-elements-in-two-lists-tp3593832p3593832.html > > Sent from the R help mailing list archive at Nabble.com. > > > > ______________________________________________ > > [hidden email] > > <http://user/SendEmail.jtp?type=node&node=3595203&i=1>mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > > ______________________________________________ > [hidden email] <http://user/SendEmail.jtp?type=node&node=3595203&i=2>mailing > list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://r.789695.n4.nabble.com/How-to-calculate-the-product-of-every-two-elements-in-two-lists-tp3593832p3595203.html > To unsubscribe from How to calculate the product of every two elements in > two lists?, click > here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3593832&code=Y2FybGFtZ21tQGdtYWlsLmNvbXwzNTkzODMyfDE3NjAxODQ0MA==>. > > -- Carla Moreira -- View this message in context: http://r.789695.n4.nabble.com/How-to-calculate-the-product-of-every-two-elements-in-two-lists-tp3593832p3595998.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ [email protected] 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.

