Bryan,

Try this.

char <- paste("X", 1:2, sep="", collapse="+")
eval(parse(text=char))

Jean


Bryan Keller <bsbkel...@gmail.com> wrote on 09/16/2012 11:04:19 PM:
> 
> Is it possible to use "paste" to write out an expression and evaluate 
it?
> Suppose I want to add two vectors X1 and X2, defined as follows:
> 
> X1 <- 1:6
> X2 <- 6:1
> 
> If I write the following it looks like what I want but is a character:
> noquote(paste(paste("X", 1, sep = ""), paste("X", 2, sep = ""), sep = 
"+"))
> 
> Is there a way to tell R that I want to evaluate the text, not just 
print
> it out as a character?
> 
> Bryan

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to