On Fri, May 15, 2009 at 3:38 PM, Romain Francois
<romain.franc...@dbmail.com> wrote:
> Hi,
>
> You can either parse and eval the string you are making, as in:
>
> eval( parse( text = paste("avg_",colname, " <- 0;", sep='') ) )
>
>
> Or you can do something like this:
>
> df[[ paste( "avg_", colname, sep = "" ) ]] <- 0
>

Thanks you so much! I used the first version and it worked.

What puzzles me, is that I am not able to use <- instead of = (my R
book says the two can be exchanged) or break the command into
different parts and execute them one after another.

I get various error messages when I try:

eval( parse( text <- paste("avg_",colname, " <- 0;", sep='') ) )

or

text = paste("avg_",colname, " <- 0;", sep='')
parse(text)
eval(parse(text))

Anyway, thanks a lot - you greatly improved the likelihood of me not
working on the weekend!

Best - P

______________________________________________
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