Passing a seq from F# to RProvider

后端 未结 2 1454
一整个雨季
一整个雨季 2021-01-24 10:24

I want to be able to pass a sequence of option float to the RProvider in F#. If I have a sequence of floats with Some float and Non

相关标签:
2条回答
  • 2021-01-24 10:37

    I think you should be able to do this just be replacing the None values with nan (this is not entirely right, because in R NA and NaN are different, but there is no way to express two different non-values for a float in F#):

    let optData4 = 
        [ 10.0; 9.0; 8.0; nan; 6.0; 5.0; 5.0; nan; 4.0; 2.0; nan ]
    
    let testData4 = 
        namedParams [
            "regPrice", optData4;]
        |> R.data_frame
    

    I have not tested this, but I think this is what we do in Deedle internally.

    0 讨论(0)
  • 2021-01-24 10:58

    You can do it with Deedle and nullable values:

    let toNullable =
           function
           | None -> Nullable()
           | Some x -> Nullable(x)
    
    let optData4 = 
        seq [Some 10.0; Some 9.0; Some 8.0; None; Some 6.0; 
            Some 5.0; Some 5.0; None; Some 4.0; Some 2.0; 
            None] 
        |> Seq.map(toNullable)
    
    let series = Series.ofNullables(optData4)
    
    let testData4 = 
        namedParams [
            "regPrice", series;]
        |> R.data_frame
    
    0 讨论(0)
提交回复
热议问题