Skip to content
Prev 306361 / 398506 Next

specifying arguments in functions and calling functions, within functions

Adding on to what Sarah has said, your function appears to limit the
functions that can be passed to it, but it does not. The character strings
"mean" and "median" will fail, but passing the function name directly will
work:
The method=c("mean", "median") is irrelevant to the function because you
never check to guarantee that only those strings are used in the function
call. This is fortunate since those strings will fail whereas passing any
function that requires a single vector as input will work just fine:
[1] NA
[1] 0.635653
Error in Scale(ex, "median") : could not find function "scl"
[1] NA
[1] 0.7050648
[1] 0.1346666 0.5190959 0.7050648 0.8304476 0.9370754
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352