n used to replace
>>> all
>>> > the entries but keep the attributes.
>>> >
>>> > and actually you function construction works with empty index
>>> >
>>> > > x<-c(1,2,5)
>>> > > letters[x]
>>> > [1] "a" "b&qu
>> > > letters[]
>> > [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q"
>> > "r&q
ot;x" "y" "z"
> >
> > It is sometimes useful not "expect" the program behavior but "inspect"
> why
> > it behaves differently.
> >
> > If you want your function to throw error when some arguments are missing
> > you need
w" "x" "y" "z"
>
> It is sometimes useful not "expect" the program behavior but "inspect" why
> it behaves differently.
>
> If you want your function to throw error when some arguments are missing
> you need to do the check y
the check yourself and not rely on programming language.
And BTW I did not know an answer before I inspected docs.
Cheers
Petr
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Stefano
> de Pretis
> Sent: Thursday, February 04, 2016 11:00
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
6 matches
Mail list logo