subset_frame: A sub-framing function

View source: R/subset_frame.R

subset_frameR Documentation

A sub-framing function

Description

The "subset_frame" function is a subsetting function intended to produce equivalently size subsets from a single data frame. This is done by evaluating the number of observations in the original data set and calculating how many rows should be in each subset for a given number of subsets. The purpose behind "subset_frame" is to break apart large data frames into smaller ones for the sake of efficiency. This could be useful for test sets for code or method testing, etc.

Usage

subset_frame(.data = NULL, n = NULL)

Arguments

.data

data.frame; a data.frame with any number of columns or rows to be sub-setted to equally sized sub-frames.

n

numeric; value of the number of sub-frames desired. Defaults to NULL in which case, if no value is entered, the frame will be divided into 10 sub-frames.

Value

array with dimensions as sub-frame rows, sub-frame columns, and and sub-frame index.

Examples

# Data.frame of 100 random observations from normal and uniform
df <- data.frame("X" = rnorm(100, 0, 1), "Y" = runif(100, 0, 1))

# Sub-frame to 2 data frames
subset_frame(df, 2)

# Sub-frame with default sub-framing
subset_frame(df)

mike-decarlo/caseling documentation built on March 17, 2023, 11:07 a.m.