Project DescriptionPass data objects from PowerShell into R and out again. This requires the R (D) COM Server.
Requirements
Installation
- Run setup.exe
- In PowerShell issue Add-PSSnapin evalR
- Use it with eval-R "cmd" [,"cmd" ...] (Attention: multiple commands need to be seperated with commas)
To use the
eval-R Cmdlet you need to issue the
Add-PSSnapin evalR everytime you start PowerShell. Therefore I save the config and supply it on startup of PowerShell
- Start PowerShell
- Add-PSSnapin evalR
- Export-Console --path c:\SomePath\MyConsole.psc1
- Modify the Shortcut of PowerShell and append -PSConsoleFile c:\SomePath\MyConsole.psc1
Samples
You can do some basic statistics (e.g. linear regression using lm()) or you can use plotting functions
- ls | select Length, @{name="ticks";expr={$_.LastWriteTime.Ticks} } | where { $_.Length -gt 0} | Eval-R "lm(Length ~ ticks)"
- ls | select Length | eval-r "hist(Length)"
- ls | select Length, @{name="ticks";expr={$_.LastWriteTime.Ticks} } | where { $_.Length -gt 0} | Eval-R "plot(Length,ticks)"
Limitations
It's very case sensitive. If you do a
select length (where
length starts with a lower-case l)and the original property is named
Length you need to use
Length as the variable name in R.
For some reason multiple commands do not use the same graphic window.
Right now not all types are serialized properly into R.
Minor Comments
Find more info on me under
http://www.eisber.net.
I just love
http://www.viemu.com.