Message-ID: <CAJL_pogbYhhLxsXQN0jjm83sZybh1nO1wE6F+CwNV18F9EkYUA@mail.gmail.com>
Date: 2024-03-01T10:25:09Z
From: Dmitri Popavenko
Subject: capture "->"
In-Reply-To: <ff87b48a-ccad-40ec-b79e-3fb4c945d3a9@gmail.com>
Dear Duncan,
On Fri, Mar 1, 2024 at 11:30?AM Duncan Murdoch <murdoch.duncan at 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]]