schema: Create a schema or extract one from an object.

View source: R/schema.R

schemaR Documentation

Create a schema or extract one from an object.

Description

Create a schema or extract one from an object.

Usage

schema(...)

Arguments

...

fields, field name/data type pairs (or a list of), or object from which to extract a schema

See Also

Schema for detailed documentation of the Schema R6 object

Examples

# Create schema using pairs of field names and data types
schema(a = int32(), b = float64())

# Create a schema using a list of pairs of field names and data types
schema(list(a = int8(), b = string()))

# Create schema using fields
schema(
  field("b", double()),
  field("c", bool(), nullable = FALSE),
  field("d", string())
)

# Extract schemas from objects
df <- data.frame(col1 = 2:4, col2 = c(0.1, 0.3, 0.5))
tab1 <- arrow_table(df)
schema(tab1)
tab2 <- arrow_table(df, schema = schema(col1 = int8(), col2 = float32()))
schema(tab2)

arrow documentation built on Nov. 25, 2023, 1:09 a.m.