[R] if syntax error :(

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jun 13 20:42:35 CEST 2006


On 6/13/06, Sarah Goslee <sarah.goslee at gmail.com> 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.

The only context I can think of is very old versions of R that used
underscore as a synonym for <- so in any sufficiently recent
version of R I don't think it can cause problems.  Whether its
good style or not is another question.

>
> 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)
> > }
> >
>
>
> --
> Sarah Goslee
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list