I might very well be wrong, but something tells me Sean really wants: sum(1:5)
or (more close to the kind of unlimited number of arguments): sum(c(1,2,3,4,5,17)) But then again, I might be mistaken. Best wishes, Adrian On Monday 09 March 2009, Gabor Grothendieck wrote: > Try this: > > sum.test <- function(...) sum(c(...)) > > More commonly one uses the list(...) construct. > > On Mon, Mar 9, 2009 at 11:32 AM, Sean Zhang <seane...@gmail.com> wrote: > > Dear R-helpers: > > I am an R newbie and have a question related to writing functions that > > accept unlimited number of input arguments. > > (I tried to peek into functions such as paste and cbind, but failed, I > > cannot see their codes..) > > > > Can someone kindly show me through a summation example? > > Say, we have input scalar, 1 2 3 4 5 > > then the ideal function, say sum.test, can do > > (1+2+3+4+5)==sum.test(1,2,3,4,5) > > > > Also sum.test can work as the number of input scalar changes. > > > > Many thanks in advance! -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd. 050025 Bucharest sector 5 Romania Tel.:+40 21 3126618 \ +40 21 3120210 / int.101 Fax: +40 21 3158391 [[alternative HTML version deleted]]
______________________________________________ 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.