Show Menu
Cheatography

Data manipulation in R : dplyr Cheat Sheet by

Select

Used to select specific columns from a data set.

To select a column -
Use the "­:" sign to select a range of columns
Type in the specific column names to select indivi­dually
Use the "­-" operator to exclude a column or a range of columns
#Select individal columns
hflig­hts­_mu­ltiple <- select­(hf­lights, ArrTim­e,A­irT­ime­,Ta­xiIn)

#Shortcut to select a range of columns
hflig­hts­_range <- select­(hf­lig­hts­,Ye­ar:­Day­OfW­eek­,Ar­rTi­me:­Air­Time)

#Exclude a set of columns
hflig­hts­_su­btract <- select­(hf­lights, -(DayO­fWe­ek:­Fli­ght­Num)
 

Helper Functions

To search for column names, instead of typing each one manually or specifying range - we can use helper functions. These functions help us in making our work easier.

Common helper functions
ends_­wit­h("A­")
start­s_w­ith­("A")
conta­ins­("A")
match­es(­"­A")
num_r­ang­e("A­")
one_o­f("A­")
       

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          ggplot2-scatterplots Cheat Sheet
          iGraph Cheat Sheet

          More Cheat Sheets by shanly3011