Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interface between Octave and R

Tags:

r

octave

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 from Octave in R such as "roots". How to do it?

Thanks for your help.

like image 773
Tony Avatar asked Jun 03 '11 05:06

Tony


3 Answers

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.

like image 164
Dirk Eddelbuettel Avatar answered Nov 03 '22 13:11

Dirk Eddelbuettel


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
like image 25
chl Avatar answered Nov 03 '22 14:11

chl


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

like image 24
user1366998 Avatar answered Nov 03 '22 15:11

user1366998