Created
April 22, 2021 17:25
-
-
Save TimTeaFan/1edd8772b44e3a4cab25bae765a03ca3 to your computer and use it in GitHub Desktop.
use where in select and across with custom function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
contains_comma <- function(x) { | |
if (is.character(x) || is.factor(x)) { | |
any(str_detect(x, ",")) | |
} else {FALSE} | |
} | |
gss_cat %>% | |
select(where(contains_comma)) | |
gss_cat %>% | |
transmute(across(where(contains_comma))) | |
gss_cat %>% | |
mutate(across(where(contains_comma)), | |
.keep = "none") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment