Skip to content
R

data.frame API Reference

R's data.frame — a tabular structure of rows and columns, the workhorse of base R data analysis.

By EZ4Code Team

data.frame functions

Base R functions for creating and manipulating data frames.

data.frame(...) -> data.frame

Creates a data frame from named vectors or columns, with stringsAsFactors defaulting to FALSE.

Returns: data.frame

nrow(x) -> integer

Returns the number of rows in a data frame or matrix.

Returns: integer

ncol(x) -> integer

Returns the number of columns in a data frame or matrix.

Returns: integer

x[i, j] (subset)

Extracts rows i and columns j from a data frame. Either may be omitted to select all.

Returns: data.frame|vector

x$col (column access)

Extracts a single column by name from a data frame, returning it as a vector.

Returns: vector

rbind(...) -> data.frame

Combines data frames or vectors by rows (stacking vertically). Columns must match.

Returns: data.frame

cbind(...) -> data.frame

Combines objects by columns (side by side). Rows must match in length.

Returns: data.frame

More R API References