Reputation: 3592
I'm using RProvider in F# to calculate some statistics of my data. When I call R function it returns SymbolicExpression type but it is really difficult to parse data from this type. In my code I count quantiles like this
let seq = R.seq(namedParams ["from", box 0;"to", box 1;"length", box 11;])
let quantiles = R.quantile(namedParams ["x", box dataWithoutNan1; "prob", box seq; "type", box 5;])
Then quantiles is of type SymbolicExpression.
val quantiles : SymbolicExpression =
0% 10% 20% 30% 40% 50%
0.000000e+00 3.203978e-03 5.366154e-03 1.101344e-02 8.259162e-02 4.533620e-01
60% 70% 80% 90% 100%
1.278446e+00 2.706468e+00 4.927400e+00 1.141095e+01 8.944235e+02
SymbolicExpression type has member Value
let quantilesValue = quantiles.Value
and it is of type obj
val quantilesValue : obj =
[|0.0; 0.003203978402; 0.00536615421; 0.01101343569; 0.08259161954;
0.4533619823; 1.278445928; 2.706467538; 4.927399755; 11.41095162;
894.4234507|]
What I trying to do is printing these values like
0.0; 0.003203978402; 0.00536615421; 0.01101343569; 0.08259161954; 0.4533619823; 1.278445928; 2.706467538; 4.927399755; 11.41095162; 894.4234507
I tried to cast these objects to Seq or to List but I was not able to do this. Any idea how to get values from SymbolicExpression in some simple way?
Upvotes: 1
Views: 89
Reputation: 3592
These code works for this issue
let quantiles = R.quantile(namedParams ["x", box dataWithoutNan1; "prob", box seq; "type", box 5;]).GetValue<double[]>()
or
let quantiles = R.quantile(namedParams ["x", box dataWithoutNan1; "prob", box seq; "type", box 5;]).GetValue<list<double>>()
Upvotes: 1