[Rd] capture "->"
Dmitri Popavenko
dm|tr|@pop@venko @end|ng |rom gm@||@com
Fri Mar 1 11:25:09 CET 2024
Dear Duncan,
On Fri, Mar 1, 2024 at 11:30 AM Duncan Murdoch <murdoch.duncan using gmail.com>
wrote:
> ...
> If you parse it with srcrefs, you could look at the source. The parser
> doesn't record whether it was A -> B or B <- A anywhere else.
>
Thank you, this gets me closer but it still needs a little push:
> foo <- function(x) {
x <- substitute(x)
return(attr(x, "srcref")[[2]])
}
> foo(A -> B)
NULL
This seems to work, however:
> foo({A -> B})
A -> B
Is there a way to treat the formula as if it was enclosed between the curly
brackets?
Dmitri
[[alternative HTML version deleted]]
More information about the R-devel
mailing list