[R] Working with additional input for user defined function
Eik Vettorazzi
E.Vettorazzi at uke.uni-hamburg.de
Tue Feb 1 14:37:48 CET 2011
Hi Christofer,
just have a look at how other functions deal with this, e.g.
> plot
function (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
More information about the R-help
mailing list