buffer: Pads an object to a desired length, either with replicates of...

View source: R/row.r

bufferR Documentation

Pads an object to a desired length, either with replicates of itself or another repeated object.

Description

Originally written for the row.r package by Craig Varrichio. Included here because the rowr package was discontinued. I use these functions in my packages

Usage

buffer(x, length.out = len(x), fill = NULL, preserveClass = TRUE)

Arguments

x

an R object

length.out

the desired length of the final output

fill

R object to fill empty rows in columns below the max size. If unspecified, repeats input rows in the same way as cbind.

preserveClass

determines whether to return an object of the same class as the original argument. Otherwise, returns a matrix.

Examples

buffer(c(1,2,3),20)
buffer(matrix(c(1,2,3,4),nrow=2),20)
buffer(list(1,2,3),20)
df<-data.frame(as.factor(c('Hello','Goodbye')),c(1,2))
buffer(df,5)
buffer((factor(x=c('Hello'))),5)

ccpluncw/ccpl_R_chutils documentation built on Feb. 28, 2024, 1:17 a.m.