AScalar holds a single value of an Arrow type.
Factory
TheScalar$create() factory method instantiates aScalar and takes the following arguments:
x: an R vector, list, ordata.frametype: an optionaldata type forx. If omitted, the type will be inferred from the data.
Methods
$ToString(): convert to a string$as_vector(): convert to an R vector$as_array(): convert to an ArrowArray$Equals(other): is this Scalar equal toother$ApproxEquals(other): is this Scalar approximately equal toother$is_valid: is this Scalar valid$null_count: number of invalid values - 1 or 0$type: Scalar type$cast(target_type, safe = TRUE, options = cast_options(safe)): cast valueto a different type
Examples
Scalar$create(pi)#> Scalar#> 3.141592653589793Scalar$create(404)#> Scalar#> 404# If you pass a vector into Scalar$create, you get a list containing your itemsScalar$create(c(1,2,3))#> Scalar#> list<item: double>[1, 2, 3]# Comparisonsmy_scalar<-Scalar$create(99)my_scalar$ApproxEquals(Scalar$create(99.00001))# FALSE#> [1] FALSEmy_scalar$ApproxEquals(Scalar$create(99.000009))# TRUE#> [1] TRUEmy_scalar$Equals(Scalar$create(99.000009))# FALSE#> [1] FALSEmy_scalar$Equals(Scalar$create(99L))# FALSE (types don't match)#> [1] FALSEmy_scalar$ToString()#> [1] "99"