Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.

Dismiss

203 views

Skip to first unread message

Apr 1, 2009, 3:52:15 PM4/1/09

to

I would like to use functions from some R libraries within Mathametica. I have seen that there exists a software called RLink but it is not readily available. Is the way to go to use the R functionaly in C/C++ and then use MathLink to call the C/C++ functions?

Thanks.

Jun 13, 2009, 6:07:27 AM6/13/09

to

I stumbled upon your question.

On Windows, it is easy to use R from within Mathematica.

You just have to download and install the

statconnDCOM server (free for noncommerial use)

from rcom.univie.ac.at

On Windows, it is easy to use R from within Mathematica.

You just have to download and install the

statconnDCOM server (free for noncommerial use)

from rcom.univie.ac.at

The following piece of code shows how you than

can use R from within Mathematica.

Needs["NETLink`"]

myR = CreateCOMObject["RCOMServerLib.StatConnector"]

myR@Init["R"]

myR@SetSymbol["xxx",12321]

result1=myR@GetSymbol["xxx"]

myR@EvaluateNoReturn["randmat<-matrix(rnorm(100),10)"]

rmat=myR@GetSymbol["randmat"]

result2=myR@Evaluate["solve(matrix(1:4,2))"]

Jun 14, 2009, 5:39:27 AM6/14/09

to

On Jun 13, 5:07 am, Erich Neuwirth <erich.neuwi...@univie.ac.at>

wrote:

> I stumbled upon your question.

> On Windows, it is easy to use R from within Mathematica.

> You just have to download and install the

> statconnDCOM server (free for noncommerial use)

> from rcom.univie.ac.at

>

> The following piece of code shows how you than

> can use R from within Mathematica.

>

> Needs["NETLink`"]

> myR = CreateCOMObject["RCOMServerLib.StatConnector"]

wrote:

> I stumbled upon your question.

> On Windows, it is easy to use R from within Mathematica.

> You just have to download and install the

> statconnDCOM server (free for noncommerial use)

> from rcom.univie.ac.at

>

> The following piece of code shows how you than

> can use R from within Mathematica.

>

> Needs["NETLink`"]

> myR = CreateCOMObject["RCOMServerLib.StatConnector"]

It seems like the actual COM object should be different. I had success

with

myR = CreateCOMObject["StatConnectorSrv.StatConnector"]

--Sasha

> myR@Init["R"]

> myR@SetSymbol["xxx",12321]

> result1=myR@GetSymbol["xxx"]

> myR@EvaluateNoReturn["randmat<-matrix(rnorm(100),10)"]

> rmat=myR@GetSymbol["randmat"]

> result2=myR@Evaluate["solve(matrix(1:4,2))"]

>

> Dobromir Tzotchev wrote:

> > I would like to use functions from some R libraries within Mathametica.=

I have seen that there exists a software called RLink but it is not readil=

y available. Is the way to go to use the R functionaly in C/C++ and t=

Jun 14, 2009, 5:39:50 AM6/14/09

to

On Jun 13, 6:07 am, Erich Neuwirth <erich.neuwi...@univie.ac.at>

wrote:

> I stumbled upon your question.

> On Windows, it is easy to use R from within Mathematica.

> You just have to download and install the

> statconnDCOM server (free for noncommerial use)

> from rcom.univie.ac.at

>

> The following piece of code shows how you than

> can use R from within Mathematica.

>

> Needs["NETLink`"]

> myR = CreateCOMObject["RCOMServerLib.StatConnector"]

> myR@Init["R"]

> myR@SetSymbol["xxx",12321]

> result1=myR@GetSymbol["xxx"]

> myR@EvaluateNoReturn["randmat<-matrix(rnorm(100),10)"]

> rmat=myR@GetSymbol["randmat"]

> result2=myR@Evaluate["solve(matrix(1:4,2))"]

>

> Dobromir Tzotchev wrote:

> > I would like to use functions from some R libraries within Mathametica.=

I have seen that there exists a software called RLink but it is not readil=

y available. Is the way to go to use the R functionaly in C/C++ and t=

hen use MathLink to call the C/C++ functions?

>

> > Thanks.

>

>

wrote:

> I stumbled upon your question.

> On Windows, it is easy to use R from within Mathematica.

> You just have to download and install the

> statconnDCOM server (free for noncommerial use)

> from rcom.univie.ac.at

>

> The following piece of code shows how you than

> can use R from within Mathematica.

>

> Needs["NETLink`"]

> myR = CreateCOMObject["RCOMServerLib.StatConnector"]

> myR@Init["R"]

> myR@SetSymbol["xxx",12321]

> result1=myR@GetSymbol["xxx"]

> myR@EvaluateNoReturn["randmat<-matrix(rnorm(100),10)"]

> rmat=myR@GetSymbol["randmat"]

> result2=myR@Evaluate["solve(matrix(1:4,2))"]

>

> Dobromir Tzotchev wrote:

I have seen that there exists a software called RLink but it is not readil=

y available. Is the way to go to use the R functionaly in C/C++ and t=

hen use MathLink to call the C/C++ functions?

>

> > Thanks.

>

>

Very interesting. I just downloading and installed RAndFriends from

rcom.univie.ac.at, which installs R, rcom, rscproxy, statconnDCOM, and

RExcel (I canceled the installation when I got to RExcel).

I order to run your code, I had to modify it as follows:

myR = CreateCOMObject["StatConnectorSrv.StatConnector"]

You example illustrates a number of methods, such as SetSymbol,

Evaluate, etc. I was able to infer

myR@Close[]

(and then use ReleaseCOMObject[myR]).

Do know where I might find the full set of methods?

--Mark

Jun 14, 2009, 7:06:26 PM6/14/09

to

RLink is readily available at

http://www.scienceops.com/Rlink2.asp

However it is not a free application.... though its cost is very

reasonable....

Hope this helps.

--David

http://scientificarts.com/worklife

Jun 15, 2009, 5:37:47 AM6/15/09

to

Hello:

I am very puzzled by the way Mathematica imports and exports data in

FITS format, I hope that somebody could give some guidance here.

I work with data in FITS format. For some reason, in the first release

of Math 6 apparently there were no way of getting the full header of

an image. This was fixed in the 6.0.2 version which I have now (I=B4m

not sure about the numeration) with the "Metadata" option in Import,

option that it is documentated only in the webpage, not in my

Documentation Center.

I am very puzzled by the way Mathematica imports and exports data in

FITS format, I hope that somebody could give some guidance here.

I work with data in FITS format. For some reason, in the first release

of Math 6 apparently there were no way of getting the full header of

an image. This was fixed in the 6.0.2 version which I have now (I=B4m

not sure about the numeration) with the "Metadata" option in Import,

option that it is documentated only in the webpage, not in my

Documentation Center.

Well, whatever, going to my question:

How can I write a fits file with my own header?

This does not work:

header=Import["file1.fits","Metadata"];

data=Table[0.,{10},{10}];

Export["test.fits",data,"Metadata"->header]

where the variable "header" is the "Metadata" of another fits file

Actually, I can not export any fits file with a header different

respect to the default one. (You can examine the header of a fits file

in a text editor)

Maybe "Metadata" is not an "Element" of the file..?? but:

Import["file1.fits","Elements"]

{"Airmass", "Author", "BitDepth", "ColorSpace", "Comments", "Data", \

"DataType", "Declination", "Device", "Equinox", "ExposureTime", \

"Graphics", "History", "HourAngle", "ImageSize", "Metadata", \

"Object", "ObservationDate", "Observer", "Organization", "Plaintext", \

"Range", "RawData", "Reference", "RightAscension", "SiderealTime", \

"TableData", "TableHeaders", "TableUnits", "Telescope"}

Thanks in advance for any help.

Atte. Andres Guzman

$Version 6.0 for Microsoft Windows (32-bit) (February 7, 2008)

$System

ps. by the way, these features where handled (not very neatly, but

effectively) in version 5.2 with ConversionOptions->{"Verbose"->True}

----------------------------------------------------------------

This message was sent using IMP, the Internet Messaging Program.

Jun 15, 2009, 5:37:58 AM6/15/09

to

For my own personal use, or for non-commercial academic use, I do not

find the listed cost of RLink as "very reasonable" -- especially given

that some of its crucial functionality can be achieved for free using

the sort of code that Eric Neuwirth posted in this group ().

find the listed cost of RLink as "very reasonable" -- especially given

that some of its crucial functionality can be achieved for free using

the sort of code that Eric Neuwirth posted in this group ().

--

Murray Eisenberg mur...@math.umass.edu

Mathematics & Statistics Dept.

Lederle Graduate Research Tower phone 413 549-1020 (H)

University of Massachusetts 413 545-2859 (W)

710 North Pleasant Street fax 413 545-1801

Amherst, MA 01003-9305

Jun 16, 2009, 9:47:49 PM6/16/09

to

Yes, I guess that I would have to agree with you Murray. (I didn't

look at the overall pricing structure of RLink, but did feel that $200

was a decently low price.)

look at the overall pricing structure of RLink, but did feel that $200

was a decently low price.)

I generally think that academic, non-commercial, non-profit, and

retirees should have a 30% or greater discount on software....

That's my general policy for what I do for Mathematica packages and

consulting.

Perhaps scienceops would respond positively to this if asked..

Best,

David

On Jun 15, 5:37 am, Murray Eisenberg <mur...@math.umass.edu> wrote:

> For my own personal use, or for non-commercial academic use, I do not

> find the listed cost of RLink as "very reasonable" -- especially given

> that some of its crucial functionality can be achieved for free using

> the sort of code that Eric Neuwirth posted in this group ().

>

> David Reiss wrote:

> > RLink is readily available at

>

> >http://www.scienceops.com/Rlink2.asp

>

> > However it is not a free application.... though its cost is very

> > reasonable....

>

> > Hope this helps.

>

> > --David

>

> >http://scientificarts.com/worklife

>

> --

> Murray Eisenberg mur...@math.umas=

s.edu

> Mathematics & Statistics Dept.

> Lederle Graduate Research Tower phone 413 549-1020 (H)

> University of Massachusetts 413 545-2859 (=

Jun 16, 2009, 9:48:32 PM6/16/09

to

Andres,

I also use FITS data. However, I read FITS files with Import [], i.e., I

have never tried to write with Export[]. Nevertheless, I would offer a guess

that you need to do the following based on experience with some other

formats I have used for Export:

Export["test.fits",{"Data"->data,"Metadata"->header}]

If you try this and it works, I can explain why (I certainly have found the

Export syntax confusing at times myself).

Best, Scot

Jun 16, 2009, 9:52:59 PM6/16/09

to

Some more remarks.

> myR = CreateCOMObject["StatConnectorSrv.StatConnector"]

There is a foreground server and a background server.

For the foreground server you have to have a running RGui (or RTerm)

with library rcom loaded.

Then

>> myR = CreateCOMObject["RCOMServerLib.StatConnector"]

will allow you to "talk" to RGui from Mathematica and then switch

windows and work within RGui.

What you are doing gives you a background server.

You cannot access this server except from Mathematica.

There is no RGui "backdoor", which is very useful for debugging.

I am still fixing a few loose ends before this will go public.

BTW: I already can get R graphics into Mathematica, and they are

embedded like Mathematica graphics.

So far, I found no reasonable vector graphics format which R can write

and Mathematica can Import. Any suggestions to that respect?

0 new messages

Search

Clear search

Close search

Google apps

Main menu