Project Description
Pass data objects from PowerShell into R and out again. This requires the R (D) COM Server.

Requirements

Installation

  1. Run setup.exe
  2. In PowerShell issue Add-PSSnapin evalR
  3. 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
  1. Start PowerShell
  2. Add-PSSnapin evalR
  3. Export-Console --path c:\SomePath\MyConsole.psc1
  4. 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.

Last edited Feb 14, 2007 at 5:12 AM by eisber, version 7