[R] Splitting lines in R script

Peter Langfelder peter.langfelder at gmail.com
Mon Aug 3 06:26:07 CEST 2015


R does not need a semicolon or other character to terminate a command;
if a line can be interpreted as a complete command, it will (first
line in your second example).

Also note that the first example may not produce what you want (if
your second example is any indication) - the result of
pbivnorm(aa,dd,tau) is added to the sum of the first two terms,
because the two minuses give a plus:

> 1- -1
[1] 2

Peter

On Sun, Aug 2, 2015 at 9:05 PM, Steven Yen <syen04 at gmail.com> wrote:
> I have a line containing summation of four components.
>
> # This works OK:
>   p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau)-
>     -pbivnorm(aa,dd,tau)-pbivnorm(bb,cc,tau)
>
> # This produces unpredicted results without warning:
>   p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau)
>     -pbivnorm(aa,dd,tau)-pbivnorm(bb,cc,tau)
>
> Is there a general rule of thumb for line breaks? Thanks you.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list