This is a very "raw" package, so it probably will not
install as smoothly as one might hope. This is partially a complexity
with Octave and g++. It is also because I don't know enough about
Octave conventions and styles. (I would be grateful to any Octave
users who would like to suggest changes to make this look more like an
Octave package.)
- Build R as a shared library
-
On Unix, this is done by configuring and building R as
follows
./configure --enable-R-shlib
make
This creates $R_HOME/bin/libR.so
which we will link against.
- Compile the Octave code in this package.
-
- First, configure the the package.
Do this by running the
configure
script
in the top-level directory.
- Change to the
src/
directory.
Compile the code using the GNUmakefile in the package with the simple command
make
or
gmake
depending on whether GNU make is the default make on your system
(or path).
If you get errors in this step, read the FAQ.html
file. If there is no answer there, let me know.
Running Octave and R
Currently, to access the R facilities from within Octave,
you will need to specify some environment variables before
running Octave.
- Add the directory containing the R shared library
(libR.so) to the
LD_LIBRARY_PATH
.
This is done with the command
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:`R RHOME`/bin
if you are using the Csh ro Tcsh shell, or as
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:`R RHOME`/bin
export LD_LIBRARY_PATH
if you are using some form of the Bourne shell (e.g. sh, bash, etc.)
-
- You will also need to add the directory in which you built
the ROctave code to the
LD_LIBRARY_PATH
.
-
This is needed to locate the
libConverters.so
file.
- Add this same directory (containing the .oct files)
to the environment variable
OCTAVE_PATH
-
At this point you should be able to invoke octave and call an R
function.
% octave
octave:1> ROctave_callR("rnorm", 10)
ans =
0.527109
1.408802
-1.789294
1.378379
1.066724
0.083658
0.712621
0.078647
0.842873
-2.706941
Duncan Temple Lang
<duncan@research.bell-labs.com>
Last modified: Thu Oct 10 14:49:55 EDT 2002