Sub runtest()
Call RInterface.StartRServer
Call RInterface.RRun("setwd(""c:\work"")")
ChDir "c:\work"
Call RInterface.RunRFile("sample.R")
Call RInterface.GetDataframe("Portfolio", Range("Sheet1!A1"))
Call RInterface.StopRServer
End Sub

and sample.R containing just the line

Portfolio = read.csv("c:\\work\\Portfolio.csv", header = T)

works on my machine when i put things in c:\work




Uma Sitaraman wrote:
> Hi,
> 
> I tried to choose the foreground option in Set R server and configure R
> but then it gives me the error "R Server not available". When I try to
> Configure, I am not able to check the foreground option of the Typed
> Server. It is also a Read-Only file. 
> 
> Also, I don't understand the below paragraph I found on the net:
> 
> Foreground server
>  
> 
> Once rcom is installed, RExcel's Set R server menu item will offer a
> button allowing to install and uninstall foreground server support in
> RExcel. 
> 
> The installation described so far already allows to use the foreground
> server from RExcel if it has been started manually. If you want to be
> able to start the foreground server from RExcel, you have to add the
> following line to your <R_HOME>etcRProfile 
> 
> require(rcom) 
> 
> Then, the Start R menu item on RExcel's menu will be able to launch the
> foreground server. 
> 
> If the package rcom is automatically loaded when RGui is started because
> of this entry in RProfile, you have to disable this autostart before you
> are able to update an existing rcom installation with install.packages. 
> 
> Where do I find R_HOME?
> 
> Regards,
> 
> 
> Uma  
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Erich
> Neuwirth
> Sent: Wednesday, January 23, 2008 5:12 PM
> To: R (D)COM and RExcel server related issues
> Subject: Re: [Rcom-l] Read Excel data
> 
> I checked with your code with some modifications,
> beause I do not have your directories.
> I got the same error because
> The the program did not execute sample.R because it could not find it.
> To debug:
> Use rcom (not (D)COM and make the window visible.
> Single step through your VBA code using F8 and
> Shift-F8. After running sample.R switch to the R Gui and
> check of your dataframe really exists.
> 
> 
> 
> Uma Sitaraman wrote:
>> Hi,
>>
>> Hi,
>>
>> Please find below my R code (in R)
>>
>> Portfolio=read.csv("Z:\\Internal\\R Files\\Portfolio.csv", header=T)
>>> Benchmark=read.csv("Z:\\Internal\\R Files\\Benchmark.csv", header=T)
>>> save.image("Z:\\Internal\\R Files\\sample")
>> Saved as Sample.R
>>
>> Here's my VBA code: to read dataframe Portfolio and then print it into
>> Excel. For some reason, it gives me the following error:
>>
>> It gives me an error "Run-time error 13- Type mismatch" and when I try
>> to debug, it stops at line below in the RInterface Module. 
>>  
>>   
>>  
>>   nrows = REvalReturn("dim(" & DFname & ")[1]") + 1.
>>
>> VBA Code:
>>
>> Private Sub CommandButton1_Click()
>> Call RInterface.StartRServer
>> Call RInterface.RRun("setwd(""Z:/Internal/R Files"")")
>> ChDir "Z:/Internal/R Files"
>> Call RInterface.RunRFile("sample.R")
>> 'Call RInterface.GetDataframe("Portfolio", Range("Sheet1!A1"))
>> Call RInterface.GetDataframe("data.frame(Portfolio)",
>> Range("Sheet1!A1"))
>> Call RInterface.StopRServer
>> End Sub
>>
>> PS: I tried both Lines 6 and 7 (that I found in the mailing list) but
>> both give the same error.
>>   
>>    
>>   
>>   I am using R (2.5.1) and RSrv200.exe.
>>
>> Regards,
>>
>> Uma  
>>
>>  
>>
>>  
>>
>>  
>>
>>  
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Uma
>> Sitaraman
>> Sent: Wednesday, January 23, 2008 9:52 AM
>> To: R (D)COM and RExcel server related issues
>> Subject: RE: [Rcom-l] Read Excel data
>>
>> Hi,
>>
>> I tried that too. It still gives me the same error.
>>
>> Regards,
>>
>> Uma  
>>
>>  
>>
>>  
>>
>>  
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Erich
>> Neuwirth
>> Sent: Tuesday, January 22, 2008 7:05 AM
>> To: R (D)COM and RExcel server related issues
>> Subject: Re: [Rcom-l] Read Excel data
>>
>>
>>
>> Uma Sitaraman wrote:
>>> Hi,
>>>
>>>  
>>>
>>> I am new to both R and RDcom, and am stuck trying to read excel data
>>> using R (through VBA code). I tried out the test code posted in the
>> web
>>> (given below)
>>>
>>>  
>>>
>>>  Sub ReadTest()
>>>
>>>>     rinterface.StartRServer
>>>>     rinterface.RRun "setwd(""c:/work/rcomtest"")"
>>>>     ChDir "c:\work\rcomtest"
>>>>     rinterface.RunRFile "read.R"
>>>>     rinterface.StopRServer
>>>>     *rinterface.getdataframe "mydat", Range("Sheet1!A1")*
>>>> End Sub
>>
>> you only can stop the server AFTER you have transferred the data to
>> excel.
>>
>>
>>
>>>> --- read.R
>>>> setwd("c:/work/rcomtest")
>>>> mydat<-read.csv("data.txt")
>>>> --- data.txt
>>>> xxx1,zzz2
>>>> 1,2
>>>> 3,4
>>>> 5,6
>>>  
>>>
>>> It gives me an error "Run-time error 13- Type mismatch" and when I
> try
>> to debug, it stops at line below in the RInterface Module. 
>>>  
>>>
>>> nrows = REvalReturn("dim(" & DFname & ")[1]") + 1.
>>>
>>>  
>>>
>>> I am using R (2.5.1) and RSrv200.exe.
>>>
>>>  
>>>
>>> Thanks in advance.
>>>
>>>  
>>>
>>> Regards,
>>>
>>>  
>>>
>>>  
>>>
>>>  
>>>
>>> -Uma    
>>>
>>>  
>>>
>>> This e-mail may contain confidential and/or privileged information.
> If
>> you are not the intended recipient (or have received this
>>> e-mail in error) please notify the sender immediately and destroy
> this
>> e-mail. Any unauthorized copying, disclosure or distribution of
>>> the material in this e-mail is strictly forbidden.  Any views or
>> opinions presented are solely those of the author and do not
>>> necessarily represent those of Amba Holdings Inc., and/or its
>> affiliates.  Important additional terms relating to this email can be
>> obtained
>>> at  http://www.ambaresearch.com/disclaimer
>>>
>>>
>>>
> ------------------------------------------------------------------------
>>> _______________________________________________
>>> Rcom-l mailing list
>>> Rcom-l@mailman.csd.univie.ac.at
>>> http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l
>>> More information (including a Wiki) at http://rcom.univie.ac.at
> 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
_______________________________________________
Rcom-l mailing list
Rcom-l@mailman.csd.univie.ac.at
http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l
More information (including a Wiki) at http://rcom.univie.ac.at

Reply via email to