RProjectConnector is a package to access the R programming language in Pharo. The following script shows how to install and configure it in a clean image, using OSWindows to automatically get the R path installation:
Install OS-Windows
1 2 3 4 |
Install RProjectConnector
1 2 3 4 | Gofer it smalltalkhubUser: 'VincentBlondeau' project: 'RProjectConnector' ; configuration; loadStable. |
1 2 3 4 5 6 7 8 9 10 | | rPath dlls | (rPath := (WinRegistry queryValue: 'InstallPath' fromKey: (WinRegistryKey localMachine queryOpenSubkey: 'Software\\R-core\\R' )) allButLast) notNil ifTrue: [ dlls := (rPath asFileReference / 'bin' / 'i386' ) entries select: [ : entry | entry extension = 'dll' ] thenDo: [ : dllEntry | dllEntry asFileReference copyTo: Smalltalk vmDirectory asFileReference / dllEntry basename ] ]. |
Finally, we could test with the Iris data set:
1 2 3 4 5 6 7 8 9 10 11 12 | | iris | iris := 'eval' asREval: {RObject findVar: 'iris' }. 'plot' asREval: { (iris at: 'Petal.Length' ). (iris at: 'Petal.Width' ). ( #pch -> 21 ). ( #xlab -> 'length' ). ( #ylab -> 'Width' ). ( #bg ->((iris at: 'Species' ) collect: [ :value | { 'red' . 'green3' . 'blue' } at: value ])). ( #main -> 'Edgar Anderson' 's Iris Data' ) }. iris inspect. |
Hope you find it useful.
0 comentarios:
Publicar un comentario