create flag

create_flag(.data, col, flag, full_name = FALSE, drop = FALSE)

Arguments

.data

data frame

col

column

flag

column entry

full_name

Logical. default F. if T, new column name is original name + flag. other wise just flag

drop

logical. default F. If T, drop original column.

Value

data frame

Examples


iris %>%
  create_flag(
  col = Species,
  flag = "versicolor",
  drop = TRUE) %>%
  head()
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width versicolor
#> 1          5.1         3.5          1.4         0.2          0
#> 2          4.9         3.0          1.4         0.2          0
#> 3          4.7         3.2          1.3         0.2          0
#> 4          4.6         3.1          1.5         0.2          0
#> 5          5.0         3.6          1.4         0.2          0
#> 6          5.4         3.9          1.7         0.4          0