-
Notifications
You must be signed in to change notification settings - Fork 25
Is there detailed manual for Rif.jl? #38
Comments
There is none yet, unfortunately, because I'd like to have the documentation in the code (the package is quite in flux, and keeping in sync a documentation separated from the code base would consume a lot of the resources available for this project - the README.md can already be a little behind at times). While there are discussions around how to document Julia code (see for example JuliaLang/julia#5200 or JuliaLang/julia#3988), I don't think that there is a solution emerging yet (I'd be happy to be corrected if there is one). In the meantime, I could add documentation as comments in the source or make sure the most frequently required feature are documented (even if it requires a manual sync for the time being). Just ask away. |
I just guess Rif.@r, Rif.@R_str and Rif.Rinenv could have similar high-level function as R-magic in rpy2, isn't it? If so, could you show me a example how to use them? Can I just create a R environment, transfer data to the R-environment from Julia, run some R commands as if I do it in R, and fetch the result in the R-enviroment back to Julia? |
This is correct. The catch might be that without unit-tests the macros might have drifted of usability as Julia moved along (all this started before a lot of tools for Julia existed/were reasonably stable) I just looked at it and it is currently broken. I am looking at it. Stay tuned. |
I after checking, and trying to remember that I wanted to do, I am not sure the macros ever worked the way intended.
Currently, the way to get close to the ipython rmagic is ipython-rmagic:
jula-Rif: Rif.R("""
x <- rnorm(10)
m <- mean(x)
""") Now, to access the objects in the environment one can do: ge = Rif.getGlobalEnv()
m = ge["m"] If you want to have this in a different environment than R's GlobalEnv, you can do the following function evalR(x::Rif.RExpression, env::Rif.REnvironment)
c_ptr = ccall(dlsym(Rif.libri, :EmbeddedR_eval),
Ptr{Void},
(Ptr{Void}, Ptr{Void}),
x.sexp, env.sexp)
if c_ptr == C_NULL
error("Error evaluating the R expression.")
end
return Rif._factory(c_ptr)
end
function parse_eval(r_code::ASCIIString, env::Rif.REnvironment)
r_expression = Rif.parseR(r_code)
return evalR(r_expression, env)
end
r_env = Rif.R("new.env()")
res = parse_eval("""
x = rnorm(10)
m = mean(x)
""", r_env)
# get the "m" out of the execution environment
r_env["m"] |
That's cool! Thanks! N=Rif.rcall(Rif.R("nrow"),RArray_Var)[1] |
It's really cool package, and extremely useful. The only problem is, to use this package, I have to guess the meaning of each function it provided, and do many frustrating try-error, or read the codes, since the documentary in the README.md are only illustrated the ice-burg of the whole function. Is there any detailed manual for this package?
The text was updated successfully, but these errors were encountered: