In future, please include a minimal, reproducible example in your question to make it easier to answer (help us to help you). In this case, I believe you may have had difficulty with this step, so here is a reproducible example and potential solution using tidyverse functions and the open source palmer penguins dataset:
library(tidyverse)
library(palmerpenguins)
# insert "yes" into three of the columns
df <- penguins %>%
na.omit() %>%
mutate(across(c(bill_length_mm, flipper_length_mm, bill_depth_mm),
~ifelse(.x > 190 | .x < 38, "yes", .x)))
head(df)
#> # A tibble: 6 × 8
#> species island bill_length_mm bill_depth_mm flipper_l…¹ body_…² sex year
#> <fct> <fct> <chr> <chr> <chr> <int> <fct> <int>
#> 1 Adelie Torgersen 39.1 yes 181 3750 male 2007
#> 2 Adelie Torgersen 39.5 yes 186 3800 fema… 2007
#> 3 Adelie Torgersen 40.3 yes yes 3250 fema… 2007
#> 4 Adelie Torgersen yes yes yes 3450 fema… 2007
#> 5 Adelie Torgersen 39.3 yes 190 3650 male 2007
#> 6 Adelie Torgersen 38.9 yes 181 3625 fema… 2007
#> # … with abbreviated variable names ¹flipper_length_mm, ²body_mass_g
# replace "yes" in only two of the columns with the column name
df %>%
mutate(across(c(bill_length_mm, flipper_length_mm),
~ifelse(.x == "yes", cur_column(), .x)))
#> # A tibble: 333 × 8
#> species island bill_length_mm bill_depth_mm flipper_…¹ body_…² sex year
#> <fct> <fct> <chr> <chr> <chr> <int> <fct> <int>
#> 1 Adelie Torgersen 39.1 yes 181 3750 male 2007
#> 2 Adelie Torgersen 39.5 yes 186 3800 fema… 2007
#> 3 Adelie Torgersen 40.3 yes flipper_l… 3250 fema… 2007
#> 4 Adelie Torgersen bill_length_mm yes flipper_l… 3450 fema… 2007
#> 5 Adelie Torgersen 39.3 yes 190 3650 male 2007
#> 6 Adelie Torgersen 38.9 yes 181 3625 fema… 2007
#> 7 Adelie Torgersen 39.2 yes flipper_l… 4675 male 2007
#> 8 Adelie Torgersen 41.1 yes 182 3200 fema… 2007
#> 9 Adelie Torgersen 38.6 yes flipper_l… 3800 male 2007
#> 10 Adelie Torgersen bill_length_mm yes flipper_l… 4400 male 2007
#> # … with 323 more rows, and abbreviated variable names ¹flipper_length_mm,
#> # ²body_mass_g
Created on 2023-05-10 with reprex v2.0.2