--Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
>> project.org] On Behalf Of Sarah Goslee
>> Sent: Wednesday, September 26, 2012 1:26 PM
>> To: K. Brand
>> Cc: r-help@r-project.org
>> Subject: Re: [R] specifying argum
rsity
College Station, TX 77843-4352
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Sarah Goslee
> Sent: Wednesday, September 26, 2012 1:26 PM
> To: K. Brand
> Cc: r-help@r-project.org
> Subject: Re: [
Hello,
You define a 2nd version of Scale with the dots argument but do not use it.
Scale2 <- function(x, method=c("mean", "median"),...) {
scl <- match.fun(method)
scl(x, ...) # Here!
}
Scale2(ex, method=median, na.rm=TRUE) # both return
Scale2(ex, method="median", na.rm=TRUE) # the
Hi,
You have some basic confusion here, and a problem likely caused by an
object named scl that exists in your global environment.
On Wed, Sep 26, 2012 at 11:56 AM, K. Brand wrote:
> Esteemed R UseRs,
>
> Regarding specifying arguments in functions and calling functions
> within functions:
>
> #
Esteemed R UseRs,
Regarding specifying arguments in functions and calling functions
within functions:
## beginning ##
## some data
ex <- rnorm(10)
ex[5] <- NA
## example function
Scale <- function(x, method=c("mean", "median")) {
scl <- method
scl(x)
}
## both return NA
Scale(ex, method=m
5 matches
Mail list logo