[R] Subset with missing argument within a function
Stefano de Pretis
ste.depo.bio at gmail.com
Thu Feb 4 11:00:11 CET 2016
Hi all,
I'm guessing what's the rationale behind this:
> subsettingFun <- function(vec, ix) vec[ix]
> subsettingFun(letters, c(1,2,5))
[1] "a" "b" "e"
> subsettingFun(letters)
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q"
"r" "s"
[20] "t" "u" "v" "w" "x" "y" "z"
If the argument "ix" is missing, I'm expecting an error not to return the
variable "vec" as it is.
I think this is VERY dangerous and does not help the development of
reliable code and the debugging.
Cheers,
Stefano
*Center for Genomic Science of IIT at SEMM*
Stefano de Pretis, PhD
*Postdoctoral fellow *
[[alternative HTML version deleted]]
More information about the R-help
mailing list