[R] sum of squares function
Joshua Wiley
jwiley.psych at gmail.com
Mon Nov 14 00:14:39 CET 2011
Hi Adam,
You're in luck, arithmetic operations in R are vectorized so it does
not take any extra effort.
x <- 1:10
sum(x^2)
cheers,
Josh
On Sun, Nov 13, 2011 at 12:20 PM, covfish87 <covfish87 at hotmail.co.uk> wrote:
> hi, basic question
>
> how do i write a function that sums the squares of elements in a vector of
> any length?
>
> thanks
> Adam
>
> --
> View this message in context: http://r.789695.n4.nabble.com/sum-of-squares-function-tp4037402p4037402.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.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, ATS Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
More information about the R-help
mailing list