[R] if syntax error :(
    Sundar Dorai-Raj 
    sundar.dorai-raj at pdf.com
       
    Tue Jun 13 20:51:33 CEST 2006
    
    
  
Sarah Goslee wrote:
> You need more brackets:
> 
> if(blah) {
>   do something
> } else {
>   do something different
> }
> 
> Sarah
> 
> PS Using underscores in variable names is not encouraged, and
> can cause you problems in certain contexts.
> 
Hi, Sarah,
Why do you say this? And in what situations will R have problems? The 
only problem I can see is using current code (with underscores in 
variable names) on extremely old versions of R. I've been using R for 6 
years now and applauded the day R-core decided to do away with 
underscore as assignment (a relic of S) and allow it in variable names. 
The one minor difficulty of using underscores of which I am aware is 
having to press `_' twice in ESS.
Thanks,
--sundar
> On 6/13/06, H. Paul Benton <hpbenton at scripps.edu> wrote:
> 
>>Umm sorry to bother everyone again but I'm having trouble with my if
>>statement. I come from a perl background so that's probably my problem! :)
>>So here is my code:
>>
>>if (any(lgAB>4) | any(lgAB<-4)){
>>        freq_AB<-hist(lgAB, type="o", plot=F)
>>        else
>>        freq_AB<-hist(lgAB, breaks=br,type ="o", plot=F)
>>}
>>
> 
> 
>
    
    
More information about the R-help
mailing list