Sébastien Bihorel
2011-Aug-31 13:25 UTC
[R] How to modify the dot-dot-dot argument using level names instead of position
Dear R-users, In the R internals manual, it is said that one can extract the elements of the dot-dot-dot argument using the special symbols ..1 or ..2. It seems to work just fine but I was wondering if there is a way one can extract or modify the content of the dot-dot-dot argument using a level name instead of its position? For instance, assuming that list(...) returns: $a [1] 1 2 3 4 5 6 7 8 9 10 $b [1] "a" "b" "c" "d" "e" "f" "g" "h" is there a way to modify level b without knowing that it is the second level? Thank you Sebastien
Sébastien Bihorel
2011-Aug-31 13:41 UTC
[R] How to modify the dot-dot-dot argument using level names instead of position
Hi, I thought "..2 <- 1" was a correct way to modify the content of the 2nd level of dot-dot-dot because it did not return any error message. However, this appears to have no effect whatsoever on the content of dot-dot-dot. So, I guess I should modify my question to: is it possible to modify the content of dot-dot-dot by any means? Thank On Wed, Aug 31, 2011 at 9:25 AM, S?bastien Bihorel <pomchip at free.fr> wrote:> Dear R-users, > > In the R internals manual, it is said that one can extract the > elements of the dot-dot-dot argument using the special symbols ..1 or > ..2. It seems to work just fine but I was wondering if there is a way > one can extract or modify the content of the dot-dot-dot argument > using a level name instead of its position? > > For instance, assuming that list(...) returns: > $a > ?[1] 1 2 3 4 5 6 7 8 9 10 > > $b > [1] "a" "b" "c" "d" "e" "f" "g" "h" > > is there a way to modify level b without knowing that it is the second level? > > Thank you > > Sebastien >
Duncan Murdoch
2011-Aug-31 13:43 UTC
[R] How to modify the dot-dot-dot argument using level names instead of position
On 31/08/2011 9:41 AM, S?bastien Bihorel wrote:> Hi, > > I thought "..2<- 1" was a correct way to modify the content of the > 2nd level of dot-dot-dot because it did not return any error message. > However, this appears to have no effect whatsoever on the content of > dot-dot-dot. So, I guess I should modify my question to: is it > possible to modify the content of dot-dot-dot by any means?Not from R code. You can achieve the same effect by converting it to a list, manipulating the list, and then using do.call() to pass it on. Duncan Murdoch> Thank > > On Wed, Aug 31, 2011 at 9:25 AM, S?bastien Bihorel<pomchip at free.fr> wrote: > > Dear R-users, > > > > In the R internals manual, it is said that one can extract the > > elements of the dot-dot-dot argument using the special symbols ..1 or > > ..2. It seems to work just fine but I was wondering if there is a way > > one can extract or modify the content of the dot-dot-dot argument > > using a level name instead of its position? > > > > For instance, assuming that list(...) returns: > > $a > > [1] 1 2 3 4 5 6 7 8 9 10 > > > > $b > > [1] "a" "b" "c" "d" "e" "f" "g" "h" > > > > is there a way to modify level b without knowing that it is the second level? > > > > Thank you > > > > Sebastien > > > > ______________________________________________ > 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.
Sébastien Bihorel
2011-Aug-31 14:42 UTC
[R] How to modify the dot-dot-dot argument using level names instead of position
Thanks Duncan On Wed, Aug 31, 2011 at 9:43 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> On 31/08/2011 9:41 AM, S?bastien Bihorel wrote: >> >> Hi, >> >> I thought "..2<- 1" was a correct way to modify the content of the >> 2nd level of dot-dot-dot because it did not return any error message. >> However, this appears to have no effect whatsoever on the content of >> dot-dot-dot. So, I guess I should modify my question to: is it >> possible to modify the content of dot-dot-dot by any means? > > Not from R code. ?You can achieve the same effect by converting it to a > list, manipulating the list, and then using do.call() to pass it on. > > Duncan Murdoch > >> Thank >> >> On Wed, Aug 31, 2011 at 9:25 AM, S?bastien Bihorel<pomchip at free.fr> >> ?wrote: >> > ?Dear R-users, >> > >> > ?In the R internals manual, it is said that one can extract the >> > ?elements of the dot-dot-dot argument using the special symbols ..1 or >> > ?..2. It seems to work just fine but I was wondering if there is a way >> > ?one can extract or modify the content of the dot-dot-dot argument >> > ?using a level name instead of its position? >> > >> > ?For instance, assuming that list(...) returns: >> > ?$a >> > ? ?[1] 1 2 3 4 5 6 7 8 9 10 >> > >> > ?$b >> > ?[1] "a" "b" "c" "d" "e" "f" "g" "h" >> > >> > ?is there a way to modify level b without knowing that it is the second >> > level? >> > >> > ?Thank you >> > >> > ?Sebastien >> > >> >> ______________________________________________ >> 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. > >