[R] single, double or no quotes in expression

Sarah Goslee sarah.goslee at gmail.com
Thu Mar 15 16:49:32 CET 2012


Hi,

You don't provide a reproducible example, but I suspect what you need is
parse():

> parse(text = "A + B")
expression(A + B)

Sarah

On Thu, Mar 15, 2012 at 10:55 AM, capy_bara <hettling at few.vu.nl> wrote:
> Dear all,
>
> I am confused about how to create an expression. I use a package (rsbml)
> which uses expressions and seems to make a difference if there is a quote
> around the expression or not.
>
> For example, package works with expressions such as
>> expression(A + B)
> but not with
>> expression("A + B")
>
> I now have a set of math expressions represented as strings, something like
> this:
>> rhs_eq<- c("0", "A + B", "B * (2+C)")
> and want to make expressions without quotes out of it.
>
> I tried
>> lapply(lapply(rhs_eq, as.symbol), as.expression)
> which only turns the double quotes into single quotes, but does not remove
> the quotes.
> I also played around with as.formula, as.name, quote and enquote, but had no
> success.
>
> Does anyone know about quotes in the expression data type?
>
> Thanks in advance,
>
> Hannes
>
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list