[R] Assigning default function arguments to themselves: Why?

Ista Zahn istazahn at gmail.com
Mon Dec 30 02:23:47 CET 2013


On Sun, Dec 29, 2013 at 6:19 PM, andrewH <ahoerner at rprogress.org> wrote:
> Dear Bill--
>
> I have seen it most often in functions that are defined or used inside of
> other functions, and need an argument from the calling function.  So I have,
> purely as a matter of imitation, taken to doing it when I am writing a
> function that wants an argument of the calling function passed to it
> unchanged, because that is how I saw it used. So for instance, in
> read.table(), scan() is called several times with reflexive argument
> assignments that include:
> file = file
> what = what
> sep = sep
> quote = quote
> comment.char = comment.char
> allowEscapes = allowEscapes
> encoding = encoding

I don't think there is anything special about the fact that the name
of the arguments
and the name of the objects they are set to have the same names. There
is no such thing as "reflexive assignment", or if there is I don't
know what it means. This example is also very different from your
original description: There you were talking about "functions [that]
contain arguments with defaults of
the form X=X". Your read.table/scan example doesn't have anything to
to with default arguments.

>
> Is this what you mean by an example that 'works'? I am sort of foggy on the
> shade of meaning conveyed by the single quotes. If not, let me know what
> kind of example you want, and I'll try and find it.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Assigning-default-function-arguments-to-themselves-Why-tp4682294p4682817.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



More information about the R-help mailing list