Please excuse me. (WRONGLY CC:ed) R-alpha: R-FAQ Memory Requirements

Martyn Plummer (plummer@iarc.fr)
Mon, 10 Mar 1997 09:46:37 +0100 (MET)


Date: Mon, 10 Mar 1997 09:46:37 +0100 (MET)
From: Martyn Plummer <plummer@iarc.fr>
To: r-testers@stat.math.ethz.ch


Here is a small collection of parse problems which range from the slightly
irritating to the bizarre. Some of them may not be bugs but they're all
annoying.  Sorry this is so long but I need to illustrate most of them.

#1) The expression in a "for" loop gets turned into a list when you
read the expression in with source(). eg if the file Rexample1 contains
the following code

do <- function()
{
        n <- 1
        for(i in 1:10) {
                n <- n*i
        }
}

Then this happens when you use source() to read it in

R> source("Rexample1")
R> do
function () 
{
        n <- 1
        for (i in 1:10) list({
                n <- n * i
        })
}

#2A) If you forget the closing brackets around an "if" statement
when editing a function, the editor (vi) returns to the R
command prompt but any further statements you type are added to
the function until you supply the closing bracket: eg if the
function do2 looks like this when you edit it

function (x)
{
        if(x > 0 ) {
                foo <- 10/x
}

then this is what happens

R> do2_vi(do2)
/tmp/00193aaa: 5 lines, 46 characters.
R> ls()
+ help()
+ }
R> do2
function (x) 
{
        if (x > 0) {
                foo <- 10/x
        }
        ls()
        help()
}

#3) If you put too many closing brackets in a function then
it is truncated: eg if it looks like this when you edit it

function (x)
{
        if (x > 0) {
                foo <- 10/x
        }}
        bar <- foo
}

then you get
R> do2_vi(do2)
/tmp/00193aaa: 7 lines, 62 characters.
R> do2
function (x) 
{
        if (x > 0) {
                foo <- 10/x
        }
}

#4) If you put a few lines of comments at the start of a function,
then the comments always appear *after* the first line of
code. 

#5) When the editor returns the error message "An error occured on line ..."
then the line number is way out - usually by a factor of 10.

Martyn
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-