How can I extract a numerical part of an R Element?
I'm using the R interface in sagemath. And I would like to get float or int values.
I have an R Element, that is an object of class sage.interfaces.r.RElement
, that contains a value that I would like to extract.
For example, given the following element:
x = [1] 6.5
How may I extract the 6.5 value as a float?
float(x)
does not work.
float(str(x).split()[1])
seems excessively crude.
For any interested in generating the example R Element, it my be done in a sagemathcell with the following code:
aList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
fences = r.quantile(aList)
x = fences[[3]]
print (type(x))
print (x)