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 ?

Thanks a lot.
Dot.

hard to say what you mean?
Maybe summing up all elements in odd positions and the ones in even positions?

myvector <- 1:6

1*3*5 + 2*4*6
sum(prod(myvector[((1:length(myvector))%%2)==1]),prod(myvector[((1:length(myvector))%%2)==0]))


Best,
Roland

______________________________________________
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.

Reply via email to