Select_helper | R Documentation |
These functions allow you to select variables based operations with prefixes and suffixes and length of names.
difference_var()
: Select variables that start with a prefix AND
NOT end wiht a suffix.
intersect_var()
: Select variables that start with a prefix
AND end wiht a suffix.
union_var()
: Select variables that start with a prefix OR
end wiht a suffix.
width_of()
: Select variables with width of n
.
width_greater_than()
: Select variables with width greater than n
.
width_less_than()
: Select variables with width less than n
.
lower_case_only()
: Select variables that contains lower case only
(e.g., "env").
upper_case_only()
: Select variables that contains upper case only
(e.g., "ENV").
title_case_only()
: Select variables that contains upper case in the first
character only (e.g., "Env").
difference_var(prefix, suffix) intersect_var(prefix, suffix) union_var(prefix, suffix) width_of(n, vars = peek_vars(fn = "width_of")) width_greater_than(n, vars = peek_vars(fn = "width_greater_than")) width_less_than(n, vars = peek_vars(fn = "width_less_than")) lower_case_only(vars = peek_vars(fn = "lower_case_only")) upper_case_only(vars = peek_vars(fn = "upper_case_only")) title_case_only(vars = peek_vars(fn = "title_case_only"))
prefix |
A prefix that start the variable name. |
suffix |
A suffix that end the variable name. |
n |
The length of variable names to select. For |
vars |
A character vector of variable names. When called from inside
selecting functions like |
library(metan) # Select variables that start with "C" and not end with "D". data_ge2 %>% select_cols(difference_var("C", "D")) # Select variables that start with "C" and end with "D". data_ge2 %>% select_cols(intersect_var("C", "D")) # Select variables that start with "C" or end with "D". data_ge2 %>% select_cols(union_var("C", "D")) # Select variables with width name of 4 data_ge2 %>% select_cols(width_of(4)) # Select variables with width name greater than 2 data_ge2 %>% select_cols(width_greater_than(2)) # Select variables with width name less than 3 data_ge2 %>% select_cols(width_less_than(3)) # Creating data with messy column names df <- head(data_ge, 3) colnames(df) <- c("Env", "gen", "Rep", "GY", "hm") select_cols(df, lower_case_only()) select_cols(df, upper_case_only()) select_cols(df, title_case_only())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.