Skip to content

Instantly share code, notes, and snippets.

@toyeiei
Created November 2, 2018 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toyeiei/8dbbc17882b7416eca190c3ff0baaa46 to your computer and use it in GitHub Desktop.
Save toyeiei/8dbbc17882b7416eca190c3ff0baaa46 to your computer and use it in GitHub Desktop.
data wrangling mini course - dplyr
# dplyr five verbs
# select columns mpg, hp, wt, cyl from mtcars dataframe
select(mtcars, mpg, hp, wt, cyl)
# select column 1 to 5, 8 and 9
select(1:5, 8, 9)
# remove column 9 and 10
select(-9, -10)
# use helper verbs in select
select(mtcars, starts_with("h"))
select(mtcars, ends_with("p"))
select(mtcars, contains("a"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment