vctrs_extension_array function

Extension type for generic typed vectors

Extension type for generic typed vectors

Most common R vector types are converted automatically to a suitable Arrow data type without the need for an extension type. For vector types whose conversion is not suitably handled by default, you can create a vctrs_extension_array(), which passes vctrs::vec_data() to Array$create() and calls vctrs::vec_restore() when the Array is converted back into an R vector.

vctrs_extension_array(x, ptype = vctrs::vec_ptype(x), storage_type = NULL) vctrs_extension_type(x, storage_type = infer_type(vctrs::vec_data(x)))

Arguments

  • x: A vctr (i.e., vctrs::vec_is() returns TRUE).
  • ptype: A vctrs::vec_ptype(), which is usually a zero-length version of the object with the appropriate attributes set. This value will be serialized using serialize(), so it should not refer to any R object that can't be saved/reloaded.
  • storage_type: The data type of the underlying storage array.

Returns

  • vctrs_extension_array() returns an ExtensionArray instance with a vctrs_extension_type().
  • vctrs_extension_type() returns an ExtensionType instance for the extension name "arrow.r.vctrs".

Examples

(array <- vctrs_extension_array(as.POSIXlt("2022-01-02 03:45", tz = "UTC"))) array$type as.vector(array) temp_feather <- tempfile() write_feather(arrow_table(col = array), temp_feather) read_feather(temp_feather) unlink(temp_feather)
  • Maintainer: Jonathan Keane
  • License: Apache License (>= 2.0)
  • Last published: 2025-02-26