[R] looking for a more efficient R code.

From: Taka Matzmoto <sell_mirage_ne_at_hotmail.com>
Date: Tue 27 Jun 2006 - 10:21:01 EST

Dear R-users

I have four simple linear models, which are all in the form of a*X+b The estimated parameter vectors are

a <- c(1,2,3,4)
b <- c(4,3,2,1)

My goal is to draw a plot where x-axis is X (range from -100 to 100) and y-axis is the sum of
all four linear models

X <- seq(-100,100, length=10000)
plot(X, sum of the four linear functions)

I started with a function for summing

summing <- function(a,b)
{temp <-0;
for (i in 1:length(a))
temp <- temp + a[i]*X+b[i]

plot(X, summing(a,b))

I am a R beginner. I am looking for a more efficient R code.

Any help or advice will be appreciated.


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 27 11:34:52 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 27 Jun 2006 - 12:12:44 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.