Description Usage Arguments Value Author(s) Examples
View source: R/add_missing_columns.R
Appends to the dataframe x
the columns not present in
colnames
. Then, it fills them with filler
.
1 | add_missing_columns(x, colnames, filler)
|
x |
A dataframe with names. |
colnames |
A vector of characters corresponding to the column
names to be added to |
filler |
A number or string to fill the new columns with, e.g., -999.99. |
The dataframe x
with extra columns.
Guillermo Basulto-Elias
1 2 3 4 | library(rmiscfun)
input_df <- data.frame(a = 1:3, b = letters[1:3])
colnames_vector <- c("a", "b", "c")
add_missing_columns(input_df, colnames_vector, -888)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.