I am trying to get R working in Julia to no avail.
Here is my input:
using Pkg
Pkg.add("RCall")
using RCall
install.packages("ape", "coda", "RColorBrewer", "fields")
Output:
ERROR: UndefVarError: `install` not defined
Stacktrace:
[1] top-level scope
@ REPL[5]:1
You need to enter the R REPL before running any R methods. Do this by using the $
symbol.
See the docs for additional setup help.
https://juliainterop.github.io/RCall.jl/stable/gettingstarted/
When an R function is called using RCall
in a Julia script (i.e., not when using the R REPL), Julia still has to parse the line that you give it as valid Julia code. Julia parses a period after an identifier, like install.packages
, as getproperty(install, :packages)
, and the error you see is because install
is not defined in this line of code.
If you want to write a script that passes something like this to R for evaluation, use the @R_str
string macro syntax:
using Pkg
Pkg.add("RCall")
using RCall
R"install.packages("ape", "coda", "RColorBrewer", "fields")"