Description Usage Arguments Details Value Author(s) Examples
function to automatically rename columns in an input data frame or data table within a function so that columns needed for the analysis can be easily accessed.
1 |
in_data |
|
in_names |
|
out_names |
|
To avoid loss of data, the function checks beforehand to see if any
columns in in_data
are named as one of out_names
. In that case, the names
of those columns are replaced as "!!!!"
a copy of in_data
with replaced column names
Lorenzo Busetto, phD (2017) lbusett@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## Not run:
in_data = iris
dumb_addcol <- function(in_data, ADD_1_VAR, ADD_2_VAR) {
out_data <- in_data %>%
dumbify(in_names = c(ADD_1_VAR, ADD_2_VAR)) %>%
dplyr::mutate(sum = ADD_1_VAR + ADD_2_VAR) %>%
undumbify(c(ADD_1_VAR, ADD_2_VAR))
out_data
}
ADD_1_VAR <- "Petal.Length"
ADD_2_VAR <- "Petal.Width"
out <- dumb_addcol(in_data, ADD_1_VAR, ADD_2_VAR)
head(out)
ADD_2_VAR <- "Sepal.Length"
out <- dumb_addcol(in_data, ADD_1_VAR, ADD_2_VAR)
head(out)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.