On 12/08/2008, at 7:09 AM, dott wrote:
Hi,
Suppose I have a vector in real number
(x1, x2, x3, x4, x5, x6)
My question is how I can get
x5*x3*x1 + x6*x4*x2 ?
v <- c(x1, x2, x3, x4, x5, x6)
m <- matrix(v,ncol=3)
sum(apply(m,1,prod))
This could easily be ``generalized'' and bundled up in a function if
so desired.
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
______________________________________________
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.