`S` and `Basic` converts a R object to a Basic object. `Symbol`, `Real` and `Constant` construct a Basic object with type "Symbol", "RealDouble"/"RealMPFR" and "Constant", respectively.
S(x)
Basic(x)
Symbol(x)
Constant(x)
Real(x, prec = NULL)
A R object.
If supplied, the argument will be parsed as a Basic object of type RealMPFR.
A Basic
S4 object.
For double vector, `S` will check whether it is a whole number -- if true, it will be converted to a Integer type. If this behavior is not desired, you can use `Basic` or `as(x, "Basic")`.
S("(x + y)^2")
#> (Pow) (x + y)^2
S(~ (x + y)^2)
#> (Pow) (x + y)^2
S(NaN)
#> (NaN) NaN
S(42)
#> (Integer) 42
Basic(42)
#> (RealDouble) 42.0
as(42, "Basic")
#> (RealDouble) 42.0
pi <- Constant("pi")
evalf(pi)
#> (RealDouble) 3.14159265358979
if (symengine_have_component("mpfr"))
evalf(pi, 300)
#> (RealMPFR,prec300) 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348
Real(42)
#> (RealDouble) 42.0
if (symengine_have_component("mpfr"))
Real(42, prec = 140)
#> (RealMPFR,prec140) 42.000000000000000000000000000000000000000