What is purpose of dot before variables (i.e. "variables") in the R Plyr package?
for instance, from the R help file:
ddply(.data, .variables, .fun = NULL, ...,
.progress = "none", .drop = TRUE, .parallel = FALSE)
Any assistance would be greatly appreciated
There may be two things going on that are confusing you.
One is the .
function in the 'plyr' package. The .
function allows you to use a variable as a link rather than referring to the value(s) the variable contains. For instance, in some functions, we want to refer to the object x
rather than the value(s) stored in x
. In the 'base' package, there is no easy, concise way of doing this, so we use the 'plyr' package to say .(x)
. The 'plyr' functions themselves use this a lot like so:
ddply(data, .(row_1), summarize, total=sum(row_1))
If we didn't use the .
function, 'ddply' would complain, because 'row_1' contains many values, when we really just want to refer to the object.
The other "." in action here is the way people use it as a character in the function arguments' names. I'm not sure what the origin is, but a lot of people seem to do it just to highlight which variables are function arguments and which variables are only part of the function's internal code. The "." is just another character, in this case.
From http://www.jstatsoft.org/v40/i01
Note that all arguments start with . This prevents name clashes with the arguments of the processing function, and helps to visually delineate arguments that control the repetition from arguments that control the individual steps. Some functions in base R use all uppercase argument names for this purpose, but I think this method is easier to type and read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With