Overview
AnArray is an immutable data array with some logical type and some length. Most logical types are contained in the base Array class; there are also subclasses for DictionaryArray, ListArray, StructArray, and other specialized types.
Array Class
Factory Method
Array$create()
Instantiates anArray and returns the appropriate subclass.
An R vector, list, or data.frame
An optional data type for
x. If omitted, the type will be inferred from the dataMethods
$IsNull()
Return true if value at index is null. Does not boundscheck.Zero-based index position
$IsValid()
Return true if value at index is valid. Does not boundscheck.Zero-based index position
$length()
Size in the number of elements this array contains.$nbytes()
Total number of bytes consumed by the elements of the array.$Equals()
Check if this array is equal to another.Another Array to compare with
$ApproxEquals()
Check if this array is approximately equal to another.Another Array to compare with
$Diff()
Return a string expressing the difference between two arrays.Another Array to compare with
$data()
Return the underlying ArrayData.$as_vector()
Convert to an R vector.$ToString()
String representation of the array.$Slice()
Construct a zero-copy slice of the array with the indicated offset and length.Starting position (zero-based)
Number of elements in the slice. If NULL, the slice goes until the end of the array
$Take()
Return anArray with values at positions given by integers.
Positions to take (R vector or Arrow Array)
$Filter()
Return anArray with values at positions where logical vector is TRUE.
Logical vector or Arrow boolean Array
Whether to keep NA values
$SortIndices()
Return anArray of integer positions that can be used to rearrange the Array in ascending or descending order.
Whether to sort in descending order
$RangeEquals()
Check if a range of values is equal to another array.Another Array to compare with
Starting index in this array
Ending index in this array
Starting index in the other array
$cast()
Alter the data in the array to change its type.The target data type
Whether to check for overflows or other unsafe conversions
Casting options
$View()
Construct a zero-copy view of this array with the given type.The data type for the view
$Validate()
Perform validation checks to determine obvious inconsistencies within the array’s internal data. This can be an expensive check, potentially O(length).Active Bindings
$null_count
The number of null entries in the array.$offset
A relative position into another array’s data, to enable zero-copy slicing.$type
Logical type of data.DictionaryArray Class
DictionaryArray is a subclass of Array for dictionary-encoded data, similar to R factors.
Factory Method
DictionaryArray$create()
An R vector or Array of integers for the dictionary indices, or an R factor
An R vector or Array of dictionary values (like R factor levels). Not needed if
x is a factorMethods
$indices()
Return the indices array.$dictionary()
Return the dictionary array.Active Bindings
$ordered
Whether the dictionary is ordered.StructArray Class
StructArray is a subclass of Array for struct (nested) data.
Factory Method
StructArray$create()
Create a StructArray from named arrays or vectors.Methods
$field()
Extract a field by integer position.Zero-based field index
$GetFieldByName()
Extract a field by name.Field name
$Flatten()
Flatten the struct array into a list of arrays.ListArray Class
ListArray is a subclass of Array for list data.
Methods
$values()
Return the values array (all list elements flattened).$value_length()
Return the length of a specific list element.Zero-based index
$value_offset()
Return the offset of a specific list element.Zero-based index
$raw_value_offsets()
Return the raw offsets array.Active Bindings
$value_type
The data type of the list values.Helper Functions
as_arrow_array()
Convert an object to an Arrow Array. This is an S3 generic that allows methods to be defined in other packages.An object to convert to an Arrow Array
A data type for the final Array. If NULL, will be inferred
concat_arrays()
Concatenate zero or more Arrays into a single array. This operation will make a copy of its input.Zero or more Array objects to concatenate
An optional type describing the desired type for the final Array
arrow_array()
Alias forArray$create().
An R object representable as an Arrow array
An optional data type. If omitted, will be inferred from the data