Skip to content
Back to formatted view

Raw Message

Message-ID: <530FC304.5080303@uw.edu>
Date: 2014-02-27T22:58:12Z
From: Daryl Morris
Subject: expressions (nesting, substitution, 2-stage evaluation)
In-Reply-To: <525620AE.5000109@uw.edu>

Hi,

I have a function which generates many plots.  To keep it simple, let's 
say I want to set the main title based on where we are in nested loops.

So, something like

vectorA = c("a","b","c")
vectorB = c("a","b","c")

for(ii in vectorA) { for(jj in vectorB) {
   plot(0:1,0:1)
   title(main = paste(ii,jj))
}

that part is easy!   The question is what if I wanted vectorA to be an 
expression?

I'd like to be able to set vectorA = 
c(expression(paste("TNF-",alpha)),expression(paste("IFN-",gamma))), and 
have the plot title show the greek letters.

Obviously, in the for-loop I could build the expression all at once, but 
there are lots of programmatic reasons I'd like to be able to have this 
program structure.  Is there a solution which modifies either/both (1) 
the setting of main in the loop (2) how I define the vector outside of 
the loop?


thanks, Daryl