SDS 192: Introduction to Data Science
select()select(contains("abc")) : select columns containing stringselect(starts_with("abc")) : select columns starting with stringselect(ends_with("abc)) : select columns ending with stringselect(-col_name) : select all columns except this columnselect(x:y) : select columns with indexes x:ydistinct() : filter to rows with distinct valuesslice(x:y) : filter to rows in index x:y==<, >, <=, >=&|!is.na()%in%filter(str_detect(col_name, "abc")) : filter to rows where string is detectedmutate(new_col_name = na_if(col_name, x) : if a value in col_name is x convert it to NA in the new columnmutate(new_col_name = na_if(col_name, " ") : if a value in col_name is " " convert it to NA in the new columnmutate(new_col_name = na_if(col_name, "NA") : if a value in col_name is "NA" convert it to NA in the new columnmutate(new_col_name = na_if(col_name, "NULL") : if a value in col_name is "NULL" convert it to NA in the new columncase_when() we can assign values based on conditions, and then assign a final value when no conditions are met. mutate(new_col_name = case_when(col_name == "Y" ~ "Yes",
col_name == "N" ~ "No",
TRUE ~ NA)
ungroup() removes the grouping metadata.