We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is the prototype
require(magrittr) #> Loading required package: magrittr select.df <- function(.x, ...) { pos <- tidyselect::eval_select(rlang::expr(c(...)), .x) rlang::set_names(.x[pos], names(pos)) } rename.df <- function(.x, ...) { pos <- tidyselect::eval_rename(rlang::expr(c(...)), .x) names(.x)[pos] <- names(pos) .x } col_contains <- function(str, dat = tidyselect::peek_data(fn = "col_contains"), .ignore_case = T) { if(.ignore_case){ str <- tolower(str) dat %>% purrr::map_lgl(~.x %>% tolower() %>% stringr::str_detect(str) %>% any) %>% colnames(dat)[.] }else{ dat %>% purrr::map_lgl(~stringr::str_detect(.x, str) %>% any) %>% colnames(dat)[.] } } d <- iris class(d)<- c( "df", class(d)) d %>% dplyr::rename(tst = col_contains("seto")) %>% head() #> Sepal.Length Sepal.Width Petal.Length Petal.Width tst #> 1 5.1 3.5 1.4 0.2 setosa #> 2 4.9 3.0 1.4 0.2 setosa #> 3 4.7 3.2 1.3 0.2 setosa #> 4 4.6 3.1 1.5 0.2 setosa #> 5 5.0 3.6 1.4 0.2 setosa #> 6 5.4 3.9 1.7 0.4 setosa d %>% dplyr::select(col_contains("ginica")) %>% head() #> Species #> 1 setosa #> 2 setosa #> 3 setosa #> 4 setosa #> 5 setosa #> 6 setosa
Created on 2020-04-03 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered:
This requires all output objects to be marked as {df} class (whichever are data.frames)
Sorry, something went wrong.
for {df} class create rename method with snake_case and camelCase options..
{df} class
snake_case
camelCase
No branches or pull requests
Here is the prototype
Created on 2020-04-03 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: