[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: import R vector into octave
From: |
Gero J Fanuth |
Subject: |
Re: import R vector into octave |
Date: |
Wed, 3 Mar 2010 16:55:50 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Aditya Bhagwat <aditya <at> biomath.ugent.be> writes:
>
> Dear all,
>
> I am using emacs for both R-scripts as well as octave-scripts. Moving a
> vector from the octave workspace to the R workspace is easy: (1) save
> the vector with the "save" function in octave and (2) read it in R with
> "read.octave{e1071}". But how to do the opposite? How to bring a vector
> from the R workspace into octave?
It is easier to exchange files between R, Matlab, Octave, Scilab, etc.
by using the ASCII format, not a specialized or proprietary one.
For transferring vector a from Octave to R:
O: save -ascii a.txt a in Octave
R: a <- scan("a.txt") in R
For transferring vector a from R to Octave:
R: write(a, "a.txt")
O: a = load("-ascii", "a.txt");
If you'd prefer a fancier format, "HDF5" could be nice (not Mac OSX):
R: library(hdf5)
hdf5save("a.txt", a)
O: a = load("-hdf5", "a.txt");
~~~ Jerome
> Many thanks for your help,
>
> Regards,
>
> Aditya
>