Learn R Programming

collapse (version 1.2.1)

A3-data-frame-manipulation: Fast Data Frame Manipulation

Description

collapse provides the following functions for fast manipulation of (mostly) data.frames.

  • fselect is a much faster alternative to dplyr::select to select columns using expressions involving column names. get_vars is a more versatile and programmer friendly function to efficiently select and replace columns by names, indices, logical vectors, regular expressions or using functions to identify columns.

  • The functions num_vars, cat_vars, char_vars, fact_vars, logi_vars and Date_vars are convenience functions to efficiently select and replace columns by data type.

  • add_vars efficiently adds new columns at any position within a data.frame (default at the end). This can be done vie replacement (i.e. add_vars(data) <- newdata) or returning the appended data (i.e. add_vars(data, newdata1, newdata2, ...)). Because of the latter, add_vars is also a more efficient alternative to cbind.data.frame.

  • fsubset is a much faster version of base::subset for efficiently subset vectors, matrices and data.frames. If the non-standard evaluation offered by fsubset is not needed, the function ss is a much faster and also more secure alternative to [.data.frame.

  • ftransform is a much faster version of base::transform, to modify and delete existing columns or append a data frame with new computed columns. settransform does all of that by reference, i.e. it modifies the data frame in the global environment. fcompute is similar to ftransform but only returns modified and computed columns in a new data frame.

Arguments

Table of Functions

Function / S3 Generic Methods Description
fselect No methods, for data.frame's Fast select columns (non-standard evaluation)
get_vars, num_vars, cat_vars, char_vars, fact_vars, logi_vars, Date_vars No methods, for data.frame's Fast select or replace columns
add_vars No methods, for data.frame's Fast add columns
fsubset default, matrix, data.frame Fast subset data (non-standard evaluation)
ss No methods, for data.frame's Fast subset data.frames's
ftransform No methods, for data.frame's Compute, modify or delete columns (non-standard evaluation)
settransform No methods, for data.frame's Compute, modify or delete columns by reference (non-standard evaluation)
fcompute No methods, for data.frame's Compute or modify columns, returned in a new data.frame (non-standard evaluation)

See Also

Quick Data Conversion, Collapse Overview