I'm an R noob with a Matlab backfround.
In RStudio I selected new R-Script. I then cut and pasted some R code into the new R-script and saved it with a file name that is the same as the function name (as you would in Matlab).
I then input some test data and try to call the function:
TESTFUNC(0,y,x)
I then get the following error:
Error: could not find function "TESTFUNC"
Such an error in Matlab suggests that the file for "TESTFUNC" is stored in the wrong location? However I have no idea if this is the same case for R? Even if it is how can I find out what the correct location is? and how to I make move the file there?
Thanks
Baz
You need to execute the code that declares the function in order to load it into memory for use. R does not pick up contents of folders without explicit command.
You can execute either of the following:
TESTFUNC<-function(y,x){INSERT STUFF HERE}
or
source("TESTFUNC.R")
The first option runs the function directly, the second executes everything in the file TESTFUNC.R. There is a third option of building a package, but I would forgo that for now.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.