Bogaso Christofer
2011-Feb-01 10:29 UTC
[R] Working with additional input for user defined function
Hi all, suppose I have following user defined function: fn1 = function(x, y, ...) { z <- x+y; u=y^2 # if something with name "add" exists in the function argument then do some calculation and return that calculated value, NOT z # if NOT then return z return(z) } As you see in the function definition, I put open space " '.' syntax " , so that user can put additional argument. However here what I want to do is, if user have additional input then above function would do some ***special calculation*** and return that value. How can I accomplice that? Thanks and regards, [[alternative HTML version deleted]]
Eik Vettorazzi
2011-Feb-01 13:37 UTC
[R] Working with additional input for user defined function
Hi Christofer, just have a look at how other functions deal with this, e.g.> plotfunction (x, y, ...) { #*snip* hasylab <- function(...) !all(is.na(pmatch(names(list(...)), "ylab"))) #*snip* got it? cheers Am 01.02.2011 11:29, schrieb Bogaso Christofer:> Hi all, suppose I have following user defined function: > > > > fn1 = function(x, y, ...) { > > z <- x+y; u=y^2 > > # if something with name "add" exists in the > function argument then do some calculation and return that calculated value, > NOT z > > # if NOT then return z > > return(z) > > } > > > > As you see in the function definition, I put open space " '.' syntax " , so > that user can put additional argument. However here what I want to do is, if > user have additional input then above function would do some ***special > calculation*** and return that value. > > > > How can I accomplice that? > > > > Thanks and regards, > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790