R Data Frames

Cool functions

Basic dplyr

  • dplyr::filter(df, condition)
    • e.g. dplyr::filter(df, age<span class="text-highlight">10 & name</span>'yo')
  • dplyr::select(df, col_names)
    • e.g. dplyr::select(df, age, -name) -> age but not name
  • dplyr::mutate(df, new_col_name = calculation_to_store)
    • e.g. dplyr::mutate(df, age_plus_one = age + 1)

Pipes

  • %>% -> pipe operations together
    • e.g. diamonds %>% filter (price > 100) %>% select(carat, price)
      • -> df will automatically be inserted into next function, no need to supply it again