[R] How to perform a substitution in a loop?

David Winsemius dwinsemius at comcast.net
Sat Aug 14 11:52:51 CEST 2010


On Aug 14, 2010, at 4:05 AM, Saji Ren wrote:

> In response to JesperHybel,  saji wrote:

> that's not a problem of {}.

Correct, as indicated by the continuation "+"

> By using {} you can put the command in one line.

Actually the curly brackets are more often used to put a series of  
commands on successive lines. If you want to force a series of  
commands after an if() else construction then "{" will start the  
series and the interpreter will continue interpreting until it reaches  
the "}" possibly many lines later. If you want to put multiple  
commands on a single line the way to do it is to separate them by  
";"'s and not hit enter until complete.

> Still you can put the command in several lines as well by pur "enter".
> That's why in the second line, the ">" becomes "+"....
>
> thank you for your reply though.

You and JesperHybel would both be following recommended list behavior  
if you would both start copying the questions or response to which you  
are replying. It is acceptable practice to trim the questions but it  
is poor form to post naked replies without any context.
>
> View this message in context: http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325075.html
-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list