[R] function not found

Thomas Lumley tlumley at u.washington.edu
Wed Apr 11 01:23:34 CEST 2001

On Tue, 10 Apr 2001, Yu-Ling Wu wrote:

> Hi,
> I have a R script with a funcion in it. When I run
> this
> script under R enviornment, it works fine. But if I go
> to DOS command prompt and type "rterm --slave < foo.r"
> it says:
>          Error: couldn't find function "myFun"
>          Execution halted
> Below is part of my code. Does anyone know why?
> Thanks,
> Yu-Ling Wu
> ================================================
> If (flag == 0) { do something... }
> else { myFun() }
> myFun <- function() {....statements.....}
> ================================================

It looks as if you haven't defined myFun() until after you tried to use
it. R is not psychic, unfortunately.

Forward references like this are fine in sets of functions, since all the
functions are read before you use them, but when you have some top-level
code it can only call functions defined earlier in the file.


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list