Skip to content
Prev 60921 / 63424 Next

Warning with new placeholder piped to data.frame extractors `[` and `[[`.

The code from gram.y that handles this looks like this in R-devel:

         /* allow top-level placeholder */
         for (SEXP a = CDR(rhs); a != R_NilValue; a = CDR(a))
             if (CAR(a) == R_PlaceholderToken) {
                 if (TAG(a) == R_NilValue)
                     raiseParseError("placeholderNotNamed", rhs,
                                     NO_VALUE, NULL, lloc_rhs,
                             _("pipe placeholder can only be used as a 
named argument (%s:%d:%d)"));
                 checkTooManyPlaceholders(rhs, CDR(a), lloc_rhs);
                 SETCAR(a, lhs);
                 return rhs;
             }

         check_rhs(rhs, lloc_rhs);

The "check_rhs" function is the one that complains about using `[` as a 
function on the right hand side.  So it is never run when there's a 
placeholder found.  Not sure if this is intentional or not.

You can see more context here: 
https://github.com/wch/r-source/blob/0ece3677bc1c4a1c76ecbcff62424d72d742d492/src/main/gram.y#L1248 
.

Duncan Murdoch
On 18/07/2022 3:48 p.m., Gabriel Becker wrote: