Interface between Octave and R
Could anyone kindly update the status on the interface between Octave and R
? ROctave
package was developed in 2002, but no new updates after that. I like to call some functions 开发者_JAVA百科from Octave in R such as "roots". How to do it?
Thanks for your help.
Expanding on chl's point of using R directly, you can also consider these CRAN packages which explicitly bring Octave functionality to R:
- pracma
- signal
And then there is the old but trusted R / Octave cheat sheet.
Edit in 2012 There is now also an emerging CRAN package RcppOctave which permits R to execute Octave code. The package is at a reasonably early stage, and works so far only on Unix.
I do not know of any active R/octave project, but if you're just after finding roots for a given polynomial you can use one of the polynom or PolynomF package:
Here is an example with P(x)= 6 + 5*x + 4*x^2 + 3*x^3 + 2*x^4 + x^5.
In octave,
octave[2] > p = 1:6;
octave[3] > roots(p)
ans =
0.55169 + 1.25335i
0.55169 - 1.25335i
-1.49180 + 0.00000i
-0.80579 + 1.22290i
-0.80579 - 1.22290i
In R,
> library(polynom)
> p <- polynomial(6:1)
> pz <- solve(p)
> pz
[1] -1.491798+0.000000i -0.805786-1.222905i -0.805786+1.222905i
[4] 0.551685-1.253349i 0.551685+1.253349i
I found this CRAN package called RcppOctave:
"Direct interface to Octave. The primary goal is to facilitate the port of Matlab/Octave scripts to R. The package enables to call any Octave functions from R and as well as browsing their documentation, passing variables between R and Octave, using R core RNGs in Octave, which ensure stochastic computations are also reproducible."
http://cran.r-project.org/web/packages/RcppOctave/index.html
精彩评论