[R] help on using 'sum' in writng a function
skim033 at student.ucr.edu
skim033 at student.ucr.edu
Sun Apr 9 21:53:38 CEST 2006
Hi, I am writing a function that includes 'sum' function
such as:
f<-function(x){
c<-c(-1,0,1)
f<-sum(c+x)
}
expecting f to be -1+x+0+x+1+x=3x. But I found out that f is
sum(x). So, f is always a scalar, which means that f(c(0,1))
is not a vector as c(0,3), but 3(0+1)=3. I would like to ask
you helping me in solving this problem. I would like to
thank you in advance.
Sungsu.
UC riverside.
More information about the R-help
mailing list