cast: Change the type of an array or column

View source: R/dplyr-funcs-type.R

castR Documentation

Change the type of an array or column

Description

This is a wrapper around the ⁠$cast()⁠ method that many Arrow objects have. It is more convenient to call inside dplyr pipelines than the method.

Usage

cast(x, to, safe = TRUE, ...)

Arguments

x

an Array, Table, Expression, or similar Arrow data object.

to

DataType to cast to; for Table and RecordBatch, it should be a Schema.

safe

logical: only allow the type conversion if no data is lost (truncation, overflow, etc.). Default is TRUE.

...

specific CastOptions to set

Value

An Expression

See Also

data-type for a list of DataType to be used with to.

Arrow C++ CastOptions documentation # nolint for the list of supported CastOptions.

Examples

## Not run: 
mtcars %>%
  arrow_table() %>%
  mutate(cyl = cast(cyl, string()))

## End(Not run)

arrow documentation built on Sept. 11, 2024, 8:02 p.m.