cols_pad {R.AlphA.Home} | R 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)
[Package R.AlphA.Home version 1.0.0 Index]