Data manipulation in R : dplyr Cheat Sheet

A Programming › R cheat sheet in English by shanly3011
14,836 views 5,138 downloads 12 Apr 2015 History
3.8 avg · 2 ratings

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
hfligh­ts_­mul­tiple <- select­(hf­lights, ArrTim­e,A­irT­ime­,Ta­xiIn)

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

#Exclude a set of columns
hfligh­ts_­sub­tract <- select­(hf­lights, -(DayO­fWe­ek:­Fli­ghtNum)

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_w­ith­("A")
starts­_wi­th(­"­A")
contai­ns(­"­A")
matche­s("A­")
num_ra­nge­("A")
one_of­("A")

Badges

Good Cheat Sheet Nice Cheat Sheet Downloaded from Unusual Locations × 3

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.