[R] RServe - How to use 'createReference' method?

Romain Francois romain.francois at dbmail.com
Tue Aug 4 18:10:50 CEST 2009


Hi,

So the file you want to read is on the client machine, and you want to 
transfer it to the server and read it into R ?

What I guess you need is :
- open a FileInputStream, many many tutorials on the web will tell you 
how this works.
- open a RFileOutputStream
- call the read(byte[] b) method of the FileInputStream as many times as 
necessary to get a byte[] each time
- send each of these byte[] to the RFileOutputStream
- close the RFileOutputStream when there is nothing more to send
- then your file is in the server side now, you can read it into R using 
whatever suitable R command read.csv, read.delim, ...

Does that help ?

Romain


On 08/04/2009 04:01 PM, joaodaniel wrote:
>
> Hello,
>
> Actually you are right. I was looking on the wrong direction. But I still
> got some doubts about how to use those methods.
>
> I want to open a file on the client machine, for example a txt
> tab-delimited, and create a dataframe with its information on R.
>
> I got to create a RFileInputStream object, using the openFile method, so it
> store the file information. Then I must use the read() method from the
> RFileInputStream to get file information. And finally, I should use the
> assing() method to relate the data with an R object. Is that right?
>
>
> Romain Francois-2 wrote:
>> Hi,
>>
>> The Rserve implementation of REngine does not support references (yet?).
>> Anyway, I don't think references are what you need here.
>>
>> You probably want the methods createFile and openFile that create
>> RFileInputStream and RFileOutputStream which you can use to transfer
>> files through the R server wire.
>> http://www.rforge.net/org/docs/org/rosuda/REngine/Rserve/RConnection.html
>>
>> Romain
>>
>> On 08/03/2009 04:57 PM, joaodaniel wrote:
>>> I need to input a txt, or xls, file from a client to R, using RServe.
>>>
>>>>  From what I've been reading, the best way to do this, is using the
>>> 'createReference' method, from REngine package.
>>> But I couldn't find any documents exemplifying it's use. I got  to upload
>>> a
>>> file from java? And then? How do i refeer the file to this method?
>>>
>>> Best Regards,
>>>
>>> J. Daniel

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/vfxe : R GUI page on the R wiki
|- http://tr.im/tlNb : RGG#155, 156 and 157
`- http://tr.im/rw0p : useR! slides




More information about the R-help mailing list