All,
This does work very well on a MAC Book PRO Running Lion (OX X 10.7.1).
In addition to the Dolphin Smalltalk, I loaded the Statistical package
"R" from:
http://sunsite.univie.ac.at/rcom/
Along with StatConnect (same URL). Statconnect allows Dolphin
Smalltalk to communicate with R via COM interface. This connection is
"Rock Solid".
I have transferee 300,000+ element vectors, between Dolphin and R
without any problems with WineSkin.
In addition, I have used and tested the Imaging DLL:
http://www.smalleranimals.com/isource.htm
This works just like a "real" Windows Machine.
I have been using this quite a lot without any problems. Been a big
skeptic of Wine until now.
Dennis
Hi Peter,
Yes, statconnDCOM is the pacage: Do the following under Windows or a
Windows VM on a MAC:
1. Download and run RandFriends - select only "R" to be installed.
statconnect (i.e. statconnDCOM) will be installed.
2. If you have R already installed, simply download the statconnDCOM
and install that piece. Install the samples as well. Make sure it
works with your version of R. there is a basic test program that will
lauch R and do some testing.
3. I will post some sample code and classes calling R from Dolphin.
This interface is solid. I have been using it for a year - no problems
from Dolphin.
Thanks
Dennis
Hi Peter,
I do not know how to import the class file into this discussion board,
so I will copy and paste the class definition.
Below the class definition is a working example. Please note that the
class definition uses the iDispatch interface so nothing
needs to be imported directly into Dolphin with any of the ActiveX
wizards. Save the class below and file it in.
Please let me know if you have any questions.
thanks
Dennis
Class Definition:
"Filed out from Dolphin Smalltalk X6.1"!
Object subclass: #StatConnect
instanceVariableNames: 'connector'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!
StatConnect guid: (GUID fromString: '{39CF4F55-65B5-4885-
ADF9-82948B584C55}')!
StatConnect comment: 'This class will allow access to the statistics
package called R throught the Statconnect COM object.
USAGE:
sc := StatConnect init.
sc StatRcmd: ''nv <- rnorm(4000, mean = 0, sd = 1)''.
vec := sc StatGetArray: ''nv''.
sc StatHist: vec title: ''Sample Histogram from Dennis''.
sc StatClose.
Instance Variables:
connector <Object> Used to hold an instace of
StatConnecotr.
'!
!StatConnect categoriesForClass!Kernel-Objects! !
!StatConnect methodsFor!
initialize
"Init the class StatConnect"
"If we already have a connector then exit"
connector notNil ifTrue: [ ^self ].
"Start the StatConnector server"
connector := IDispatch createObject:
'StatConnectorSrv.StatConnector'.
connector invoke: 'init' with: 'R'.
^self.
!
StatClose
"Shutdown the class StatConnect"
"If we already have a connector then exit"
connector isNil ifTrue: [ ^self ].
"Stop the StatConnector server"
connector invoke: 'close'.
^self.
!
StatGetArray: aString
"Return a defined variable frmo R via StatConnector. For example nv
<- rnorm(3000, mean = 6, sd = 1) - www := StatGetVar: 'nv'."
"If no connector then exit"
connector isNil ifTrue: [ ^self ].
"Create a tmp Vector in R"
^(connector invoke: 'GetSymbol' with: aString) asArray.
!
StatHist: anArray title: Title acolor: acolor
"Plot a Histogram using the Stat Connector. anArray is a simple
array on integers Title: Give the Graph a title"
| cmd |
"If we already have a connector then exit"
connector isNil ifTrue: [ ^self ].
"Create a tmp Vector in R"
connector invoke: 'SetSymbol' with: 'tmp' with: anArray.
"The command"
cmd := ' plot((1:256), tmp, type="h", col=c(" ', acolor, ' "),
main=" ',Title, ' ", xlab="Color Value", ylab="Color Counts")'.
"Histogram plot"
connector invoke: 'EvaluateNoReturn' with: cmd.
!
StatRcmd: aString
"Send a command in String to StatConnector (ex: nv <- rnorm(3000,
mean = 6, sd = 1) - must be a valid R string"
"If no connector then exit"
connector isNil ifTrue: [ ^self ].
"Create a tmp Vector in R"
connector invoke: 'EvaluateNoReturn' with: aString.
! !
!StatConnect categoriesFor: #initialize!public! !
!StatConnect categoriesFor: #StatClose!public! !
!StatConnect categoriesFor: #StatGetArray:!public! !
!StatConnect categoriesFor: #StatHist:title:acolor:!public! !
!StatConnect categoriesFor: #StatRcmd:!public! !
!StatConnect class methodsFor!
init
"Initialize a newly created instance of the stat connector"
^(self new initialize)! !
!StatConnect class categoriesFor: #init!public! !
Here is the working example using the class above:
sc := StatConnect init.
sc StatRcmd: 'nv <- rnorm(4000, mean = 0, sd = 1)'.
vec := sc StatGetArray: 'nv'.
vec inspect.
sc StatRcmd: 'plot(cars)'.
sc StatClose.
Thanks
Dennis