addmissingcolumns | R Documentation |
Add missing columns
addmissingcolumns(df, cols)
df |
a data table |
cols |
a character vector of all possible columns |
This function modifies by reference.
This function compares a data tables columns to a character vector of all
possible column names. Any columns not present in df
that are present in cols
are added to df
with a value of NA_character
.
a data table
x <- data.table::data.table(a = c(1,2,3))
cols <- c("a","b","c")
nsqipr:::addmissingcolumns(x, cols)
x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.