Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for option types in RProvider #179

Open
s952163 opened this issue Sep 14, 2016 · 1 comment
Open

Add support for option types in RProvider #179

s952163 opened this issue Sep 14, 2016 · 1 comment

Comments

@s952163
Copy link

s952163 commented Sep 14, 2016

Currently lists that contain the Option type cannot be directly passed to RProvider but have to be converted.

The following generates an error:

let ints = [Some 2; None; Some 4; Some 5; None]
let floats = [Some 2.; None; Some 4.; Some 5.; None]
let strings = [Some "a"; None; Some "c"; Some "d"; None]

strings |> R.data_frame
floats  |> R.plot 

System.Exception: No converter registered for type Microsoft.FSharp.Collections.FSharpList1[[Microsoft.FSharp.Core.FSharpOption1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]] or any of its base types
at [email protected](String message) in C:\Tomas\Public\bmc\FSharp.RProvider\src\RProvider\RInterop.fs:line 164
at RProvider.RInteropInternal.REngine.SetValue(REngine this, Object value, FSharpOption1 symbolName) in C:\Tomas\Public\bmc\FSharp.RProvider\src\RProvider\RInterop.fs:line 274 at RProvider.RInteropInternal.toR(Object value) in C:\Tomas\Public\bmc\FSharp.RProvider\src\RProvider\RInterop.fs:line 287 at RProvider.RInterop.passArg@447(List1 tempSymbols, Object arg) in C:\Tomas\Public\bmc\FSharp.RProvider\src\RProvider\RInterop.fs:line 450
at [email protected](IEnumerable1& next) in C:\Tomas\Public\bmc\FSharp.RProvider\src\RProvider\RInterop.fs:line 470 at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase1.MoveNextImpl()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable1 source) at RProvider.RInterop.callFunc(String packageName, String funcName, IEnumerable1 argsByName, Object[] varArgs) in C:\Tomas\Public\bmc\FSharp.RProvider\src\RProvider\RInterop.fs:line 466
at <StartupCode$FSI_0064>.$FSI_0064.main@() in C:\Users\verepet\documents\visual studio 2015\Projects\StackOverflow6\StackOverflow6\Script5.fsx:line 90
Stopped due to error

Workaround is to convert the lists:


let floats' = [2.; nan; 4.; 5.; nan]
let strings' = ["a"; "NA"; "c"; "d"; "NA"]

strings' |> R.data_frame
floats' |> R.plot
val it : SymbolicExpression =   ...
1   a
2  NA
3   c
4   d
5  NA

Ideally the type provider should take care of this conversion.

@tpetricek tpetricek added Type: Enhancement New feature or request up-for-grabs labels Sep 28, 2016
@tpetricek
Copy link
Member

This would be a nice feature to have - I'm marking this as up-for-grabs, in case someone wants to send a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants