Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

Table class

Source:R/table.R
Table-class.Rd

A Table is a sequence ofchunked arrays. Theyhave a similar interface torecord batches, but they can becomposed from multiple record batches or chunked arrays.

S3 Methods and Usage

Tables are data-frame-like, and many methods you expect to work onadata.frame are implemented forTable. This includes[,[[,$,names,dim,nrow,ncol,head, andtail. You can also pullthe data from an Arrow table into R withas.data.frame(). See theexamples.

A caveat about the$ method: becauseTable is anR6 object,$ is also used to access the object's methods (see below). Methods takeprecedence over the table's columns. So,tab$Slice would return the"Slice" method function even if there were a column in the table called"Slice".

R6 Methods

In addition to the more R-friendly S3 methods, aTable object hasthe following R6 methods that map onto the underlying C++ methods:

  • $column(i): Extract aChunkedArray by integer position from the table

  • $ColumnNames(): Get all column names (called bynames(tab))

  • $nbytes(): Total number of bytes consumed by the elements of the table

  • $RenameColumns(value): Set all column names (called bynames(tab) <- value)

  • $GetColumnByName(name): Extract aChunkedArray by string name

  • $field(i): Extract aField from the table schema by integer position

  • $SelectColumns(indices): Return newTable with specified columns, expressed as 0-based integers.

  • $Slice(offset, length = NULL): Create a zero-copy view starting at theindicated integer offset and going for the given length, or to the endof the table ifNULL, the default.

  • $Take(i): return anTable with rows at positions given byintegersi. Ifi is an ArrowArray orChunkedArray, it will becoerced to an R vector before taking.

  • $Filter(i, keep_na = TRUE): return anTable with rows at positions where logicalvector or Arrow boolean-type(Chunked)Arrayi isTRUE.

  • $SortIndices(names, descending = FALSE): return anArray of integer rowpositions that can be used to rearrange theTable in ascending or descendingorder by the first named column, breaking ties with further named columns.descending can be a logical vector of length one or of the same length asnames.

  • $serialize(output_stream, ...): Write the table to the givenOutputStream

  • $cast(target_schema, safe = TRUE, options = cast_options(safe)): Alterthe schema of the record batch.

There are also some active bindings:

  • $num_columns

  • $num_rows

  • $schema

  • $metadata: Returns the key-value metadata of theSchema as a named list.Modify or replace by assigning in (tab$metadata <- new_metadata).All list elements are coerced to string. Seeschema() for more information.

  • $columns: Returns a list ofChunkedArrays


[8]ページ先頭

©2009-2025 Movatter.jp