-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I faced this issue today: I have an R algorithm that should return a list of doubles. Whenever it returns a list that does contain NAs only, it will be decoded as a SexpArrayBool and .AsDoubles will run into an NotSupportedException.
So, now I am doing this workaround:
public IList<double> GetDoublesVector(string symbolOrExpression)
{
try
{
return _rConnection.Eval(symbolOrExpression).AsDoubles.ToList();
}
catch (NotSupportedException e)
{
return ((ICollection<Sexp>) _rConnection.Eval(symbolOrExpression).Values).Select<Sexp, double>(s =>
{
if (s.IsNa)
{
return Double.NaN;
}
else
{
return s.AsDouble;
}
}).ToList();
}
}
Reactions are currently unavailable