cols_pad: Add Variables to ease data usage in a Pivot Table

View source: R/cols_pad.R

cols_padR Documentation

Add Variables to ease data usage in a Pivot Table

Description

Adds dummy columns to reach the number specified by the user. this is mostly useful to ensure straightforward and easy data updating when using pivot tables in Excel. It allows replacement of the previous data sheet by the new one, without having to take care about the number of columns, which will always be the same.

Usage

cols_pad(data, nCols = 100, colPrefix = "x_")

Arguments

data

The data frame to which dummy columns will be added.

nCols

the total number of columns required : default is 100

colPrefix

A string used as the prefix for the names of dummy columns.

Value

A data frame with the specified total number of columns.

Examples

table <- data.frame(a = 1:5, b = letters[1:5])
extraTable <- cols_pad(table, nCols = 6, colPrefix = "extra_")
print(extraTable)



R.AlphA.Home documentation built on April 3, 2025, 5:53 p.m.