[R] summation coding

Bert Gunter gunter.berton at gene.com
Fri Oct 19 07:15:16 CEST 2012


Have you read the Introduction to R tutorial? You seem unaware of even
the most basic stuff, especially vectorization and subscripting.

Also, this smells like homework, and we don't do homework here.

-- Bert

On Thu, Oct 18, 2012 at 12:33 PM, djbanana <karl79264219 at gmail.com> wrote:
> I would like to code the following in R: a1(b1+b2+b3) + a2(b1+b3+b4) +
> a3(b1+b2+b4) + a4(b1+b2+b3)
>
> or in summation notation: sum_{i=1, j\neq i}^{4} a_i * b_i
>
> I realise this is the same as: sum_{i=1, j=1}^{4} a_i * b_i - sum_{i=j} a_i
> * b_i
>
> would appreciate some help.
>
> Thank you.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/summation-coding-tp4646678.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm




More information about the R-help mailing list