nameColumns | R Documentation |
This function, changes the column names of the given table (data.frame) and checks for the column classes
nameColumns(dataset, columns, classes = NULL, convert = T)
dataset |
A table(data.frame) on which the column names is going to change |
columns |
A named list of characters indicating which names should change to what. List values should be a subset of original column names and list names are names to which the original column names should change |
classes |
a named list of characters inducating the required classes of each column. List names should be the new column names and values are classes required for each column |
convert |
A boolean indicating if columns should be coerced to the required class. Function returns error is coercing is not possible. Defaulted is TRUE. If FALSE, the function verifies the column classes and returns error if don't match. |
A table(data.frame) same class as the input table dataset
Data = data.frame(x = c(1,2,3), y = c('10', '20', '30'), z = c('One', 'two', 'three'), stringsAsFactors = F) Data %>% nameColumns(columns = list(XX = 'x', YY = 'y', ZZ = 'z'), classes = list(XX = 'integer', YY = 'numeric'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.