Skip to content
Back to formatted view

Raw Message

Message-ID: <F3DDBD82-F442-4F4D-ACCB-67C6BDAE6DF4@comcast.net>
Date: 2011-04-01T17:22:26Z
From: David Winsemius
Subject: How to paste a vector of expressions and a character vector?
In-Reply-To: <42460E70-FC82-41D6-B6E2-F3F92712F935@web.de>

On Apr 1, 2011, at 12:32 PM, Marius Hofert wrote:

> Dear expeRts,
>
> I know I can't paste expressions in the normal way, but I just  
> couldn't figure out
> how to get the following (I want to paste a character vector to an  
> expression vector)
> right with bquote() or substitute.
>
> vec1 <- c("a", expression(tilde(b)), "c")
> vec2 <- c("1", "2", "3")
> main <- as.expression(paste(vec1, vec2))
> plot(0,0, main=main[2])

Do not use `paste` ... it coerces your expression to a character  
value ... use `c` instead:

 > main <- as.expression(c(vec1, vec2))
 > plot(1,1, main=main[2])

And then, even the as.expression is superfluous:

 > main <- c(vec1, vec2)
 > plot(1,1, main=main[2])

-- 

David Winsemius, MD
West Hartford, CT