这似乎是RTypeProvider
只能处理相同类型的namedParams
。是这样吗?如何创建多种类型的数据框与RTypeProvider
例如,
open RDotNet
open RProvider
type foo = {
Which: string
Qty: float option
}
let someFoos = [{Which = "that"; Qty = Some 4.0}; {Which = "other"; Qty = Some 2.0}]
let thingForR =
namedParams [
"which", someFoos |> List.map (fun x -> x.Which);
"qty", someFoos |> List.map (fun x -> x.Qty);
]
|> R.data_frame
,因为我如果我扭转了thingForR
让利的顺序得到的x.Qty
一个错误说
This expression was expected to have type
string
but here has type
float option
不工作,那么我得到相反的错误:
let thingForR =
namedParams [
"qty", someFoos |> List.map (fun x -> x.Qty);
"which", someFoos |> List.map (fun x -> x.Which);
]
|> R.data_frame
在这里,错误x.Which
是
This expression was expected to have type
float option
but here has type
string
namedParams
中的字典能不能有不同的类型吗?如果是这样,你如何在F#中创建一个不同类型的数据帧并将它们传递给R?
这是一个F#错误,欢迎到强类型语言:-)你需要'box'它。但是您也会遇到选项类型的问题。我不知道为什么,但没有转换器。让我先查找相关答案。 – s952163