[R] trouble with R com and python
ebetzinger@free.fr
ebetzinger at free.fr
Thu Oct 2 09:58:44 CEST 2003
hi there
i tried to use R from python
my pc is an intel 1600 with win98; python is python 2.2; R is rw1062, and R (D)COM Server V1.2
when i use the sample code provided in the readme.html, no problem, but when i try to read a file, a get a traceback error
(please see code enclosed)
has anyone ever tried to read file using python, or send commands from libraries (MASS...) ?
is there a tutorial for Rcom ( well, i tried to find one with google, but it didn't work :-(( )
thanks in advance ;-)
regards
emmanuel
the python code is the following :
---------------------------
---------------------------
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> from win32com.client import Dispatch
>>> sc=Dispatch("StatConnectorSrv.StatConnector")
>>> sc.Init("R")
>>> res = sc.Evaluate("2+2")
>>> res
4.0
>>> res = sc.Evaluate("library(modreg)")
>>> sc.Evaluate("library(modreg)")
(u'methods', u'ctest', u'mva', u'modreg', u'nls', u'ts', u'base')
>>> sc.Evaluate("library(MASS)")
(u'MASS', u'methods', u'ctest', u'mva', u'modreg', u'nls', u'ts', u'base')
##### no pb till here!!
### but if i try to read a file
>>> sc.Evaluate('do<-read.table("c:/data.txt", header=TRUE)')
Traceback (most recent call last):
File "<pyshell#11>", line 1, in ?
sc.Evaluate('do<-read.table("c:/data.txt", header=TRUE)')
File "<COMObject StatConnectorSrv.StatConnector>", line 2, in Evaluate
File "C:\PYTHON22\lib\site-packages\win32com\client\dynamic.py", line 237, in _ApplyTypes_
result = apply(self._oleobj_.InvokeTypes, (dispid, LCID, wFlags, retType, argTypes) + args)
com_error: (-2147352567, 'Une exception est apparue.', (0, None, None, None, 0, -2147221500), None)
++++ nota bene : : " Une exception est apparue." means " an exception occured"
>>>
More information about the R-help
mailing list