[R] writing several command line in R console
Spencer Graves
spencer.graves at pdf.com
Tue Mar 4 04:00:03 CET 2003
You can start the first line with "(". Then everything you write will
NOT be syntactically complelte until you issue the closing ")". I
learned this from Venables and Ripley, Modern Applied Statistics with S.
The "+" sign in front of each line is NOT something you should enter: R
changes its prompt to tell you that the previous line was not
syntactically complete.
I prefer to keep my code someplace else and then transfer a complete
function into R at one time. See
"http://socserv.socsci.mcmaster.ca/jfox/Books/Companion/ESS/index.html"
Does this answer your questions?
Best Wishes,
Spencer Graves
Vincent Stoliaroff wrote:
>
> Hi R lovers
>
> I would like to know how to step to the next line in the R console
> editor without breaking the continuity of my code
> more clearly : if for example I write a function, so far i have to write
> the all code inside on the same line wich may become obscure as the
> function is more and more complex.
> I would like to do like in the example of the manuels:
>
>> twosam <- function(y1, y2) {
>
> n1 <- length(y1); n2 <- length(y2)
> yb1 <- mean(y1); yb2 <- mean(y2) s1 <- var(y1); s2 <- var(y2)
> s <- ((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
> tst <- (yb1 - yb2)/sqrt(s2*(1/n1 + 1/n2)) tst }
>
>
> all I can do is something like that:
>
>> twosam <- function(y1, y2) { n1 <- length(y1); n2 <- length(y2)
>
>
> + yb1 <- mean(y1); yb2 <- mean(y2) s1 <- var(y1); s2 <-
> var(y2)
> + s <- ((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
> + tst <- (yb1 - yb2)/sqrt(s2*(1/n1 + 1/n2)) tst }
>
> with the sign "+" in front of each line
> What does this sign mean? and how could I solve my problems
> Thanks
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list