[R Course] Data Wrangling with R: Reshaping and Subsetting

R Courses Data Wrangling

Learn how to reshape and subset your data.

Thierry Warin https://warin.ca/aboutme.html (HEC Montréal and CIRANO (Canada))https://www.hec.ca/en/profs/thierry.warin.html
05-26-2019


The package tidyverse will be used for this course.

Reshaping

Combine

To combine vectors into data frame:

fruits <- c("Banana","Apple", "Peach")
fruits
[1] "Banana" "Apple"  "Peach" 

A vector called “a” containing the values 1,2,3 is created.

numbers <- c(2, 5, 3)
numbers
[1] 2 5 3

A vector called “b” containing the values 4,5,6 is created.

shoppingcart <- data.frame(Fruits = fruits, Values = numbers)
Fruits Values
Banana 2
Apple 5
Peach 3

A dataframe containing a column called “Fruits” equal to the vector “fruits” and another called “Values” equal to the vector “numbers”.

Another optimized way of doing it, is by creating the vectors directly inside the function:

basket <- data.frame(Fruits = c("Banana","Apple", "Peach"), Values = c(2, 5, 3))

A dataframe is created with a column called “Fruits” containing “Banana”,“Apple”, “Peach” and another called “Values” containing the values: 2, 5, 3.

Fruits Values
Banana 2
Apple 5
Peach 3

Arrange

To order rows by values of a column.

Ascending

To order values from low to high:

basket <- arrange(basket, Values)
Fruits Values
Banana 2
Peach 3
Apple 5

Descending

The desc() function allow to order values from high to low:

basket <- arrange(basket, desc(Values))
Fruits Values
Apple 5
Peach 3
Banana 2

Spread

Let’s create a new dataframe to show you the use of the following functions:

df <- data.frame(country=c("USA", "CA", "FR","USA", "CA", "FR","USA", "CA", "FR"), 
                 date= c(2017, 2017, 2017, 2018, 2018, 2018, 2019, 2019, 2019), 
                 GDP=c(2700,1500,4200,2800,1600,4300,2900,1700,4400))
country date GDP
USA 2017 2700
CA 2017 1500
FR 2017 4200
USA 2018 2800
CA 2018 1600
FR 2018 4300
USA 2019 2900
CA 2019 1700
FR 2019 4400

A dataframe called “df” is created containing a column “country” with USA, CA, FR, a column “date” with 2017, 2018, 2019 and a column “GDP” with 2700, 1500, 4200.

dfYear <- spread(df, date, GDP)
country 2017 2018 2019
CA 1500 1600 1700
FR 4200 4300 4400
USA 2700 2800 2900
dfCountry <- spread(df, country, GDP)
date CA FR USA
2017 1500 4200 2700
2018 1600 4300 2800
2019 1700 4400 2900

Gather

dfYear <- gather(dfYear, "date", "GDP", 2:4)
country date GDP
CA 2017 1500
FR 2017 4200
USA 2017 2700
CA 2018 1600
FR 2018 4300
USA 2018 2800
CA 2019 1700
FR 2019 4400
USA 2019 2900

Note: the number 2:4 in the gather() function refers to the columns that will be transformed in rows to create the column date.

dfCountry <- gather(dfCountry, "country", "GDP", 2:4)
date country GDP
2017 CA 1500
2018 CA 1600
2019 CA 1700
2017 FR 4200
2018 FR 4300
2019 FR 4400
2017 USA 2700
2018 USA 2800
2019 USA 2900

Note: the numbers 2:4 in the gather() function refers to the second, third and fourth columns (CA, FR, USA) that will be transformed in rows.

Separate

To separate one column into several:

df <- separate(df, date, c("year", "month", "day"), sep = "-")
country year month day GDP
USA 2017 NA NA 2700
CA 2017 NA NA 1500
FR 2017 NA NA 4200
USA 2018 NA NA 2800
CA 2018 NA NA 1600
FR 2018 NA NA 4300
USA 2019 NA NA 2900
CA 2019 NA NA 1700
FR 2019 NA NA 4400

The column “date” will be separated into three columns “year”, “month”, “day”. As the date contains the symbol “-” (2019-09-05), it will be used to seperate the column into 3 columns.

Unite

To unite several columns into one.

dataDash <- unite(df, "date", c("year", "month", "day"), sep="-")
country date GDP
USA 2017-NA-NA 2700
CA 2017-NA-NA 1500
FR 2017-NA-NA 4200
USA 2018-NA-NA 2800
CA 2018-NA-NA 1600
FR 2018-NA-NA 4300
USA 2019-NA-NA 2900
CA 2019-NA-NA 1700
FR 2019-NA-NA 4400
dataSlash <- unite(df, "date", c("year", "month", "day"), sep="/")
country date GDP
USA 2017/NA/NA 2700
CA 2017/NA/NA 1500
FR 2017/NA/NA 4200
USA 2018/NA/NA 2800
CA 2018/NA/NA 1600
FR 2018/NA/NA 4300
USA 2019/NA/NA 2900
CA 2019/NA/NA 1700
FR 2019/NA/NA 4400

Subsetting

Let’s work with the built-in dataset “iris”:

data("iris")

Observations

To subset observations (rows), here some functions.

Filter

To extract rows that meet logical criteria.

subset7 <- filter(iris, Sepal.Length > 7.7)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
7.9 3.8 6.4 2 virginica

The rows where “Sepal.Length” is is greater than 7.7 will be kept.


subset2 <- filter(iris, Sepal.Width < 2.3)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.0 2.0 3.5 1.0 versicolor
6.0 2.2 4.0 1.0 versicolor
6.2 2.2 4.5 1.5 versicolor
6.0 2.2 5.0 1.5 virginica

The rows where “Sepal.Width” is less than 2.3 will be kept.


You can combine multiple logical operator by storing the result in a subset data.

subsetV <- filter(iris, Species == "versicolor" & Petal.Length >= 4.1 & Petal.Length <= 4.2)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.9 3.0 4.2 1.5 versicolor
5.8 2.7 4.1 1.0 versicolor
5.6 3.0 4.1 1.3 versicolor
5.6 2.7 4.2 1.3 versicolor
5.7 3.0 4.2 1.2 versicolor
5.7 2.9 4.2 1.3 versicolor
5.7 2.8 4.1 1.3 versicolor

The rows where “Species” is exactly equal to “versicolor” and Petal.Length is between 4.1 and 4.2 will be kept.

Distinct

To remove duplicate rows:

distinct(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
4.6 3.4 1.4 0.3 setosa
5.0 3.4 1.5 0.2 setosa
4.4 2.9 1.4 0.2 setosa
4.9 3.1 1.5 0.1 setosa
5.4 3.7 1.5 0.2 setosa
4.8 3.4 1.6 0.2 setosa
4.8 3.0 1.4 0.1 setosa
4.3 3.0 1.1 0.1 setosa
5.8 4.0 1.2 0.2 setosa
5.7 4.4 1.5 0.4 setosa
5.4 3.9 1.3 0.4 setosa
5.1 3.5 1.4 0.3 setosa
5.7 3.8 1.7 0.3 setosa
5.1 3.8 1.5 0.3 setosa
5.4 3.4 1.7 0.2 setosa
5.1 3.7 1.5 0.4 setosa
4.6 3.6 1.0 0.2 setosa
5.1 3.3 1.7 0.5 setosa
4.8 3.4 1.9 0.2 setosa
5.0 3.0 1.6 0.2 setosa
5.0 3.4 1.6 0.4 setosa
5.2 3.5 1.5 0.2 setosa
5.2 3.4 1.4 0.2 setosa
4.7 3.2 1.6 0.2 setosa
4.8 3.1 1.6 0.2 setosa
5.4 3.4 1.5 0.4 setosa
5.2 4.1 1.5 0.1 setosa
5.5 4.2 1.4 0.2 setosa
4.9 3.1 1.5 0.2 setosa
5.0 3.2 1.2 0.2 setosa
5.5 3.5 1.3 0.2 setosa
4.9 3.6 1.4 0.1 setosa
4.4 3.0 1.3 0.2 setosa
5.1 3.4 1.5 0.2 setosa
5.0 3.5 1.3 0.3 setosa
4.5 2.3 1.3 0.3 setosa
4.4 3.2 1.3 0.2 setosa
5.0 3.5 1.6 0.6 setosa
5.1 3.8 1.9 0.4 setosa
4.8 3.0 1.4 0.3 setosa
5.1 3.8 1.6 0.2 setosa
4.6 3.2 1.4 0.2 setosa
5.3 3.7 1.5 0.2 setosa
5.0 3.3 1.4 0.2 setosa
7.0 3.2 4.7 1.4 versicolor
6.4 3.2 4.5 1.5 versicolor
6.9 3.1 4.9 1.5 versicolor
5.5 2.3 4.0 1.3 versicolor
6.5 2.8 4.6 1.5 versicolor
5.7 2.8 4.5 1.3 versicolor
6.3 3.3 4.7 1.6 versicolor
4.9 2.4 3.3 1.0 versicolor
6.6 2.9 4.6 1.3 versicolor
5.2 2.7 3.9 1.4 versicolor
5.0 2.0 3.5 1.0 versicolor
5.9 3.0 4.2 1.5 versicolor
6.0 2.2 4.0 1.0 versicolor
6.1 2.9 4.7 1.4 versicolor
5.6 2.9 3.6 1.3 versicolor
6.7 3.1 4.4 1.4 versicolor
5.6 3.0 4.5 1.5 versicolor
5.8 2.7 4.1 1.0 versicolor
6.2 2.2 4.5 1.5 versicolor
5.6 2.5 3.9 1.1 versicolor
5.9 3.2 4.8 1.8 versicolor
6.1 2.8 4.0 1.3 versicolor
6.3 2.5 4.9 1.5 versicolor
6.1 2.8 4.7 1.2 versicolor
6.4 2.9 4.3 1.3 versicolor
6.6 3.0 4.4 1.4 versicolor
6.8 2.8 4.8 1.4 versicolor
6.7 3.0 5.0 1.7 versicolor
6.0 2.9 4.5 1.5 versicolor
5.7 2.6 3.5 1.0 versicolor
5.5 2.4 3.8 1.1 versicolor
5.5 2.4 3.7 1.0 versicolor
5.8 2.7 3.9 1.2 versicolor
6.0 2.7 5.1 1.6 versicolor
5.4 3.0 4.5 1.5 versicolor
6.0 3.4 4.5 1.6 versicolor
6.7 3.1 4.7 1.5 versicolor
6.3 2.3 4.4 1.3 versicolor
5.6 3.0 4.1 1.3 versicolor
5.5 2.5 4.0 1.3 versicolor
5.5 2.6 4.4 1.2 versicolor
6.1 3.0 4.6 1.4 versicolor
5.8 2.6 4.0 1.2 versicolor
5.0 2.3 3.3 1.0 versicolor
5.6 2.7 4.2 1.3 versicolor
5.7 3.0 4.2 1.2 versicolor
5.7 2.9 4.2 1.3 versicolor
6.2 2.9 4.3 1.3 versicolor
5.1 2.5 3.0 1.1 versicolor
5.7 2.8 4.1 1.3 versicolor
6.3 3.3 6.0 2.5 virginica
5.8 2.7 5.1 1.9 virginica
7.1 3.0 5.9 2.1 virginica
6.3 2.9 5.6 1.8 virginica
6.5 3.0 5.8 2.2 virginica
7.6 3.0 6.6 2.1 virginica
4.9 2.5 4.5 1.7 virginica
7.3 2.9 6.3 1.8 virginica
6.7 2.5 5.8 1.8 virginica
7.2 3.6 6.1 2.5 virginica
6.5 3.2 5.1 2.0 virginica
6.4 2.7 5.3 1.9 virginica
6.8 3.0 5.5 2.1 virginica
5.7 2.5 5.0 2.0 virginica
5.8 2.8 5.1 2.4 virginica
6.4 3.2 5.3 2.3 virginica
6.5 3.0 5.5 1.8 virginica
7.7 3.8 6.7 2.2 virginica
7.7 2.6 6.9 2.3 virginica
6.0 2.2 5.0 1.5 virginica
6.9 3.2 5.7 2.3 virginica
5.6 2.8 4.9 2.0 virginica
7.7 2.8 6.7 2.0 virginica
6.3 2.7 4.9 1.8 virginica
6.7 3.3 5.7 2.1 virginica
7.2 3.2 6.0 1.8 virginica
6.2 2.8 4.8 1.8 virginica
6.1 3.0 4.9 1.8 virginica
6.4 2.8 5.6 2.1 virginica
7.2 3.0 5.8 1.6 virginica
7.4 2.8 6.1 1.9 virginica
7.9 3.8 6.4 2.0 virginica
6.4 2.8 5.6 2.2 virginica
6.3 2.8 5.1 1.5 virginica
6.1 2.6 5.6 1.4 virginica
7.7 3.0 6.1 2.3 virginica
6.3 3.4 5.6 2.4 virginica
6.4 3.1 5.5 1.8 virginica
6.0 3.0 4.8 1.8 virginica
6.9 3.1 5.4 2.1 virginica
6.7 3.1 5.6 2.4 virginica
6.9 3.1 5.1 2.3 virginica
6.8 3.2 5.9 2.3 virginica
6.7 3.3 5.7 2.5 virginica
6.7 3.0 5.2 2.3 virginica
6.3 2.5 5.0 1.9 virginica
6.5 3.0 5.2 2.0 virginica
6.2 3.4 5.4 2.3 virginica
5.9 3.0 5.1 1.8 virginica

After using the distinct() function, 1 row was removed.

Sample

To randomly select fraction of rows:

sample_frac(iris, 0.05, replace = TRUE)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.4 3.4 1.7 0.2 setosa
6.1 3.0 4.6 1.4 versicolor
6.1 2.9 4.7 1.4 versicolor
6.7 3.1 4.7 1.5 versicolor
6.5 3.2 5.1 2.0 virginica
5.2 3.4 1.4 0.2 setosa
7.2 3.2 6.0 1.8 virginica
5.0 2.0 3.5 1.0 versicolor

Randomly keep 5% of the dataframe “iris”.

To randomly select n rows:

sample_n(iris, 10, replace = TRUE)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
6.7 3.1 5.6 2.4 virginica
6.0 3.0 4.8 1.8 virginica
6.2 2.2 4.5 1.5 versicolor
5.0 3.4 1.5 0.2 setosa
6.4 2.8 5.6 2.1 virginica
6.0 3.0 4.8 1.8 virginica
6.4 2.8 5.6 2.2 virginica
4.7 3.2 1.3 0.2 setosa
6.3 2.8 5.1 1.5 virginica
6.3 3.4 5.6 2.4 virginica

Randomly keep 10 rows of the dataframe “iris”.

Slice

To Select rows by position:

slice(iris, 10:15)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
4.9 3.1 1.5 0.1 setosa
5.4 3.7 1.5 0.2 setosa
4.8 3.4 1.6 0.2 setosa
4.8 3.0 1.4 0.1 setosa
4.3 3.0 1.1 0.1 setosa
5.8 4.0 1.2 0.2 setosa

Keep the row 10 to the row 15 of the dataframe “iris”.

Top n

Select and order top n entries (by group if grouped data):

top_n(iris, 1, Sepal.Length)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
7.9 3.8 6.4 2 virginica

Keep the highest value in column “Sepal.Length”.

Variables

To subset variables (columns), here some functions:

Select

To select columns by name:

select(iris, Sepal.Width, Petal.Length, Species)

The columns “Sepal.Width”, “Petal.Length” and “Species” will be kept.

Sepal.Width Petal.Length Species
3.5 1.4 setosa
3.0 1.4 setosa
3.2 1.3 setosa
3.1 1.5 setosa
3.6 1.4 setosa
3.9 1.7 setosa
3.4 1.4 setosa
3.4 1.5 setosa
2.9 1.4 setosa
3.1 1.5 setosa
3.7 1.5 setosa
3.4 1.6 setosa
3.0 1.4 setosa
3.0 1.1 setosa
4.0 1.2 setosa
4.4 1.5 setosa
3.9 1.3 setosa
3.5 1.4 setosa
3.8 1.7 setosa
3.8 1.5 setosa
3.4 1.7 setosa
3.7 1.5 setosa
3.6 1.0 setosa
3.3 1.7 setosa
3.4 1.9 setosa
3.0 1.6 setosa
3.4 1.6 setosa
3.5 1.5 setosa
3.4 1.4 setosa
3.2 1.6 setosa
3.1 1.6 setosa
3.4 1.5 setosa
4.1 1.5 setosa
4.2 1.4 setosa
3.1 1.5 setosa
3.2 1.2 setosa
3.5 1.3 setosa
3.6 1.4 setosa
3.0 1.3 setosa
3.4 1.5 setosa
3.5 1.3 setosa
2.3 1.3 setosa
3.2 1.3 setosa
3.5 1.6 setosa
3.8 1.9 setosa
3.0 1.4 setosa
3.8 1.6 setosa
3.2 1.4 setosa
3.7 1.5 setosa
3.3 1.4 setosa
3.2 4.7 versicolor
3.2 4.5 versicolor
3.1 4.9 versicolor
2.3 4.0 versicolor
2.8 4.6 versicolor
2.8 4.5 versicolor
3.3 4.7 versicolor
2.4 3.3 versicolor
2.9 4.6 versicolor
2.7 3.9 versicolor
2.0 3.5 versicolor
3.0 4.2 versicolor
2.2 4.0 versicolor
2.9 4.7 versicolor
2.9 3.6 versicolor
3.1 4.4 versicolor
3.0 4.5 versicolor
2.7 4.1 versicolor
2.2 4.5 versicolor
2.5 3.9 versicolor
3.2 4.8 versicolor
2.8 4.0 versicolor
2.5 4.9 versicolor
2.8 4.7 versicolor
2.9 4.3 versicolor
3.0 4.4 versicolor
2.8 4.8 versicolor
3.0 5.0 versicolor
2.9 4.5 versicolor
2.6 3.5 versicolor
2.4 3.8 versicolor
2.4 3.7 versicolor
2.7 3.9 versicolor
2.7 5.1 versicolor
3.0 4.5 versicolor
3.4 4.5 versicolor
3.1 4.7 versicolor
2.3 4.4 versicolor
3.0 4.1 versicolor
2.5 4.0 versicolor
2.6 4.4 versicolor
3.0 4.6 versicolor
2.6 4.0 versicolor
2.3 3.3 versicolor
2.7 4.2 versicolor
3.0 4.2 versicolor
2.9 4.2 versicolor
2.9 4.3 versicolor
2.5 3.0 versicolor
2.8 4.1 versicolor
3.3 6.0 virginica
2.7 5.1 virginica
3.0 5.9 virginica
2.9 5.6 virginica
3.0 5.8 virginica
3.0 6.6 virginica
2.5 4.5 virginica
2.9 6.3 virginica
2.5 5.8 virginica
3.6 6.1 virginica
3.2 5.1 virginica
2.7 5.3 virginica
3.0 5.5 virginica
2.5 5.0 virginica
2.8 5.1 virginica
3.2 5.3 virginica
3.0 5.5 virginica
3.8 6.7 virginica
2.6 6.9 virginica
2.2 5.0 virginica
3.2 5.7 virginica
2.8 4.9 virginica
2.8 6.7 virginica
2.7 4.9 virginica
3.3 5.7 virginica
3.2 6.0 virginica
2.8 4.8 virginica
3.0 4.9 virginica
2.8 5.6 virginica
3.0 5.8 virginica
2.8 6.1 virginica
3.8 6.4 virginica
2.8 5.6 virginica
2.8 5.1 virginica
2.6 5.6 virginica
3.0 6.1 virginica
3.4 5.6 virginica
3.1 5.5 virginica
3.0 4.8 virginica
3.1 5.4 virginica
3.1 5.6 virginica
3.1 5.1 virginica
2.7 5.1 virginica
3.2 5.9 virginica
3.3 5.7 virginica
3.0 5.2 virginica
2.5 5.0 virginica
3.0 5.2 virginica
3.4 5.4 virginica
3.0 5.1 virginica

Helper functions for select

To select columns whose name contains a character string:

select(iris, contains("."))

The columns containing a “dot” will be kept.

Sepal.Length Sepal.Width Petal.Length Petal.Width
5.1 3.5 1.4 0.2
4.9 3.0 1.4 0.2
4.7 3.2 1.3 0.2
4.6 3.1 1.5 0.2
5.0 3.6 1.4 0.2
5.4 3.9 1.7 0.4
4.6 3.4 1.4 0.3
5.0 3.4 1.5 0.2
4.4 2.9 1.4 0.2
4.9 3.1 1.5 0.1
5.4 3.7 1.5 0.2
4.8 3.4 1.6 0.2
4.8 3.0 1.4 0.1
4.3 3.0 1.1 0.1
5.8 4.0 1.2 0.2
5.7 4.4 1.5 0.4
5.4 3.9 1.3 0.4
5.1 3.5 1.4 0.3
5.7 3.8 1.7 0.3
5.1 3.8 1.5 0.3
5.4 3.4 1.7 0.2
5.1 3.7 1.5 0.4
4.6 3.6 1.0 0.2
5.1 3.3 1.7 0.5
4.8 3.4 1.9 0.2
5.0 3.0 1.6 0.2
5.0 3.4 1.6 0.4
5.2 3.5 1.5 0.2
5.2 3.4 1.4 0.2
4.7 3.2 1.6 0.2
4.8 3.1 1.6 0.2
5.4 3.4 1.5 0.4
5.2 4.1 1.5 0.1
5.5 4.2 1.4 0.2
4.9 3.1 1.5 0.2
5.0 3.2 1.2 0.2
5.5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 3.3 6.0 2.5
5.8 2.7 5.1 1.9
7.1 3.0 5.9 2.1
6.3 2.9 5.6 1.8
6.5 3.0 5.8 2.2
7.6 3.0 6.6 2.1
4.9 2.5 4.5 1.7
7.3 2.9 6.3 1.8
6.7 2.5 5.8 1.8
7.2 3.6 6.1 2.5
6.5 3.2 5.1 2.0
6.4 2.7 5.3 1.9
6.8 3.0 5.5 2.1
5.7 2.5 5.0 2.0
5.8 2.8 5.1 2.4
6.4 3.2 5.3 2.3
6.5 3.0 5.5 1.8
7.7 3.8 6.7 2.2
7.7 2.6 6.9 2.3
6.0 2.2 5.0 1.5
6.9 3.2 5.7 2.3
5.6 2.8 4.9 2.0
7.7 2.8 6.7 2.0
6.3 2.7 4.9 1.8
6.7 3.3 5.7 2.1
7.2 3.2 6.0 1.8
6.2 2.8 4.8 1.8
6.1 3.0 4.9 1.8
6.4 2.8 5.6 2.1
7.2 3.0 5.8 1.6
7.4 2.8 6.1 1.9
7.9 3.8 6.4 2.0
6.4 2.8 5.6 2.2
6.3 2.8 5.1 1.5
6.1 2.6 5.6 1.4
7.7 3.0 6.1 2.3
6.3 3.4 5.6 2.4
6.4 3.1 5.5 1.8
6.0 3.0 4.8 1.8
6.9 3.1 5.4 2.1
6.7 3.1 5.6 2.4
6.9 3.1 5.1 2.3
5.8 2.7 5.1 1.9
6.8 3.2 5.9 2.3
6.7 3.3 5.7 2.5
6.7 3.0 5.2 2.3
6.3 2.5 5.0 1.9
6.5 3.0 5.2 2.0
6.2 3.4 5.4 2.3
5.9 3.0 5.1 1.8

To select columns whose name matches a regular expression:

select(iris, matches(".w."))  

The columns containing a “w” will be kept.

Sepal.Width Petal.Width
3.5 0.2
3.0 0.2
3.2 0.2
3.1 0.2
3.6 0.2
3.9 0.4
3.4 0.3
3.4 0.2
2.9 0.2
3.1 0.1
3.7 0.2
3.4 0.2
3.0 0.1
3.0 0.1
4.0 0.2
4.4 0.4
3.9 0.4
3.5 0.3
3.8 0.3
3.8 0.3
3.4 0.2
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3.0 1.8

To select all columns between Sepal.Length and Petal.Width (inclusive):

select(iris, Sepal.Length:Petal.Width)

All columns starting from the column “Sepal.Length” to “Petal.Width” will be kept.

Sepal.Length Sepal.Width Petal.Length Petal.Width
5.1 3.5 1.4 0.2
4.9 3.0 1.4 0.2
4.7 3.2 1.3 0.2
4.6 3.1 1.5 0.2
5.0 3.6 1.4 0.2
5.4 3.9 1.7 0.4
4.6 3.4 1.4 0.3
5.0 3.4 1.5 0.2
4.4 2.9 1.4 0.2
4.9 3.1 1.5 0.1
5.4 3.7 1.5 0.2
4.8 3.4 1.6 0.2
4.8 3.0 1.4 0.1
4.3 3.0 1.1 0.1
5.8 4.0 1.2 0.2
5.7 4.4 1.5 0.4
5.4 3.9 1.3 0.4
5.1 3.5 1.4 0.3
5.7 3.8 1.7 0.3
5.1 3.8 1.5 0.3
5.4 3.4 1.7 0.2
5.1 3.7 1.5 0.4
4.6 3.6 1.0 0.2
5.1 3.3 1.7 0.5
4.8 3.4 1.9 0.2
5.0 3.0 1.6 0.2
5.0 3.4 1.6 0.4
5.2 3.5 1.5 0.2
5.2 3.4 1.4 0.2
4.7 3.2 1.6 0.2
4.8 3.1 1.6 0.2
5.4 3.4 1.5 0.4
5.2 4.1 1.5 0.1
5.5 4.2 1.4 0.2
4.9 3.1 1.5 0.2
5.0 3.2 1.2 0.2
5.5 3.5 1.3 0.2
4.9 3.6 1.4 0.1
4.4 3.0 1.3 0.2
5.1 3.4 1.5 0.2
5.0 3.5 1.3 0.3
4.5 2.3 1.3 0.3
4.4 3.2 1.3 0.2
5.0 3.5 1.6 0.6
5.1 3.8 1.9 0.4
4.8 3.0 1.4 0.3
5.1 3.8 1.6 0.2
4.6 3.2 1.4 0.2
5.3 3.7 1.5 0.2
5.0 3.3 1.4 0.2
7.0 3.2 4.7 1.4
6.4 3.2 4.5 1.5
6.9 3.1 4.9 1.5
5.5 2.3 4.0 1.3
6.5 2.8 4.6 1.5
5.7 2.8 4.5 1.3
6.3 3.3 4.7 1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.3
5.6 2.8 4.9 2.0
7.7 2.8 6.7 2.0
6.3 2.7 4.9 1.8
6.7 3.3 5.7 2.1
7.2 3.2 6.0 1.8
6.2 2.8 4.8 1.8
6.1 3.0 4.9 1.8
6.4 2.8 5.6 2.1
7.2 3.0 5.8 1.6
7.4 2.8 6.1 1.9
7.9 3.8 6.4 2.0
6.4 2.8 5.6 2.2
6.3 2.8 5.1 1.5
6.1 2.6 5.6 1.4
7.7 3.0 6.1 2.3
6.3 3.4 5.6 2.4
6.4 3.1 5.5 1.8
6.0 3.0 4.8 1.8
6.9 3.1 5.4 2.1
6.7 3.1 5.6 2.4
6.9 3.1 5.1 2.3
5.8 2.7 5.1 1.9
6.8 3.2 5.9 2.3
6.7 3.3 5.7 2.5
6.7 3.0 5.2 2.3
6.3 2.5 5.0 1.9
6.5 3.0 5.2 2.0
6.2 3.4 5.4 2.3
5.9 3.0 5.1 1.8

To select columns whose name starts with a character string:

select(iris, starts_with("Sepal")) 

The columns starting with the word “Sepal” will be kept.

Sepal.Length Sepal.Width
5.1 3.5
4.9 3.0
4.7 3.2
4.6 3.1
5.0 3.6
5.4 3.9
4.6 3.4
5.0 3.4
4.4 2.9
4.9 3.1
5.4 3.7
4.8 3.4
4.8 3.0
4.3 3.0
5.8 4.0
5.7 4.4
5.4 3.9
5.1 3.5
5.7 3.8
5.1 3.8
5.4 3.4
5.1 3.7
4.6 3.6
5.1 3.3
4.8 3.4
5.0 3.0
5.0 3.4
5.2 3.5
5.2 3.4
4.7 3.2
4.8 3.1
5.4 3.4
5.2 4.1
5.5 4.2
4.9 3.1
5.0 3.2
5.5 3.5
4.9 3.6
4.4 3.0
5.1 3.4
5.0 3.5
4.5 2.3
4.4 3.2
5.0 3.5
5.1 3.8
4.8 3.0
5.1 3.8
4.6 3.2
5.3 3.7
5.0 3.3
7.0 3.2
6.4 3.2
6.9 3.1
5.5 2.3
6.5 2.8
5.7 2.8
6.3 3.3
4.9 2.4
6.6 2.9
5.2 2.7
5.0 2.0
5.9 3.0
6.0 2.2
6.1 2.9
5.6 2.9
6.7 3.1
5.6 3.0
5.8 2.7
6.2 2.2
5.6 2.5
5.9 3.2
6.1 2.8
6.3 2.5
6.1 2.8
6.4 2.9
6.6 3.0
6.8 2.8
6.7 3.0
6.0 2.9
5.7 2.6
5.5 2.4
5.5 2.4
5.8 2.7
6.0 2.7
5.4 3.0
6.0 3.4
6.7 3.1
6.3 2.3
5.6 3.0
5.5 2.5
5.5 2.6
6.1 3.0
5.8 2.6
5.0 2.3
5.6 2.7
5.7 3.0
5.7 2.9
6.2 2.9
5.1 2.5
5.7 2.8
6.3 3.3
5.8 2.7
7.1 3.0
6.3 2.9
6.5 3.0
7.6 3.0
4.9 2.5
7.3 2.9
6.7 2.5
7.2 3.6
6.5 3.2
6.4 2.7
6.8 3.0
5.7 2.5
5.8 2.8
6.4 3.2
6.5 3.0
7.7 3.8
7.7 2.6
6.0 2.2
6.9 3.2
5.6 2.8
7.7 2.8
6.3 2.7
6.7 3.3
7.2 3.2
6.2 2.8
6.1 3.0
6.4 2.8
7.2 3.0
7.4 2.8
7.9 3.8
6.4 2.8
6.3 2.8
6.1 2.6
7.7 3.0
6.3 3.4
6.4 3.1
6.0 3.0
6.9 3.1
6.7 3.1
6.9 3.1
5.8 2.7
6.8 3.2
6.7 3.3
6.7 3.0
6.3 2.5
6.5 3.0
6.2 3.4
5.9 3.0

To select columns whose name ends with a character string:

select(iris, ends_with("Length"))  

The columns ending with the word “Length” will be kept.

Sepal.Length Petal.Length
5.1 1.4
4.9 1.4
4.7 1.3
4.6 1.5
5.0 1.4
5.4 1.7
4.6 1.4
5.0 1.5
4.4 1.4
4.9 1.5
5.4 1.5
4.8 1.6
4.8 1.4
4.3 1.1
5.8 1.2
5.7 1.5
5.4 1.3
5.1 1.4
5.7 1.7
5.1 1.5
5.4 1.7
5.1 1.5
4.6 1.0
5.1 1.7
4.8 1.9
5.0 1.6
5.0 1.6
5.2 1.5
5.2 1.4
4.7 1.6
4.8 1.6
5.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1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
4.6 3.4 1.4 0.3 setosa
5.0 3.4 1.5 0.2 setosa
4.4 2.9 1.4 0.2 setosa
4.9 3.1 1.5 0.1 setosa
5.4 3.7 1.5 0.2 setosa
4.8 3.4 1.6 0.2 setosa
4.8 3.0 1.4 0.1 setosa
4.3 3.0 1.1 0.1 setosa
5.8 4.0 1.2 0.2 setosa
5.7 4.4 1.5 0.4 setosa
5.4 3.9 1.3 0.4 setosa
5.1 3.5 1.4 0.3 setosa
5.7 3.8 1.7 0.3 setosa
5.1 3.8 1.5 0.3 setosa
5.4 3.4 1.7 0.2 setosa
5.1 3.7 1.5 0.4 setosa
4.6 3.6 1.0 0.2 setosa
5.1 3.3 1.7 0.5 setosa
4.8 3.4 1.9 0.2 setosa
5.0 3.0 1.6 0.2 setosa
5.0 3.4 1.6 0.4 setosa
5.2 3.5 1.5 0.2 setosa
5.2 3.4 1.4 0.2 setosa
4.7 3.2 1.6 0.2 setosa
4.8 3.1 1.6 0.2 setosa
5.4 3.4 1.5 0.4 setosa
5.2 4.1 1.5 0.1 setosa
5.5 4.2 1.4 0.2 setosa
4.9 3.1 1.5 0.2 setosa
5.0 3.2 1.2 0.2 setosa
5.5 3.5 1.3 0.2 setosa
4.9 3.6 1.4 0.1 setosa
4.4 3.0 1.3 0.2 setosa
5.1 3.4 1.5 0.2 setosa
5.0 3.5 1.3 0.3 setosa
4.5 2.3 1.3 0.3 setosa
4.4 3.2 1.3 0.2 setosa
5.0 3.5 1.6 0.6 setosa
5.1 3.8 1.9 0.4 setosa
4.8 3.0 1.4 0.3 setosa
5.1 3.8 1.6 0.2 setosa
4.6 3.2 1.4 0.2 setosa
5.3 3.7 1.5 0.2 setosa
5.0 3.3 1.4 0.2 setosa
7.0 3.2 4.7 1.4 versicolor
6.4 3.2 4.5 1.5 versicolor
6.9 3.1 4.9 1.5 versicolor
5.5 2.3 4.0 1.3 versicolor
6.5 2.8 4.6 1.5 versicolor
5.7 2.8 4.5 1.3 versicolor
6.3 3.3 4.7 1.6 versicolor
4.9 2.4 3.3 1.0 versicolor
6.6 2.9 4.6 1.3 versicolor
5.2 2.7 3.9 1.4 versicolor
5.0 2.0 3.5 1.0 versicolor
5.9 3.0 4.2 1.5 versicolor
6.0 2.2 4.0 1.0 versicolor
6.1 2.9 4.7 1.4 versicolor
5.6 2.9 3.6 1.3 versicolor
6.7 3.1 4.4 1.4 versicolor
5.6 3.0 4.5 1.5 versicolor
5.8 2.7 4.1 1.0 versicolor
6.2 2.2 4.5 1.5 versicolor
5.6 2.5 3.9 1.1 versicolor
5.9 3.2 4.8 1.8 versicolor
6.1 2.8 4.0 1.3 versicolor
6.3 2.5 4.9 1.5 versicolor
6.1 2.8 4.7 1.2 versicolor
6.4 2.9 4.3 1.3 versicolor
6.6 3.0 4.4 1.4 versicolor
6.8 2.8 4.8 1.4 versicolor
6.7 3.0 5.0 1.7 versicolor
6.0 2.9 4.5 1.5 versicolor
5.7 2.6 3.5 1.0 versicolor
5.5 2.4 3.8 1.1 versicolor
5.5 2.4 3.7 1.0 versicolor
5.8 2.7 3.9 1.2 versicolor
6.0 2.7 5.1 1.6 versicolor
5.4 3.0 4.5 1.5 versicolor
6.0 3.4 4.5 1.6 versicolor
6.7 3.1 4.7 1.5 versicolor
6.3 2.3 4.4 1.3 versicolor
5.6 3.0 4.1 1.3 versicolor
5.5 2.5 4.0 1.3 versicolor
5.5 2.6 4.4 1.2 versicolor
6.1 3.0 4.6 1.4 versicolor
5.8 2.6 4.0 1.2 versicolor
5.0 2.3 3.3 1.0 versicolor
5.6 2.7 4.2 1.3 versicolor
5.7 3.0 4.2 1.2 versicolor
5.7 2.9 4.2 1.3 versicolor
6.2 2.9 4.3 1.3 versicolor
5.1 2.5 3.0 1.1 versicolor
5.7 2.8 4.1 1.3 versicolor
6.3 3.3 6.0 2.5 virginica
5.8 2.7 5.1 1.9 virginica
7.1 3.0 5.9 2.1 virginica
6.3 2.9 5.6 1.8 virginica
6.5 3.0 5.8 2.2 virginica
7.6 3.0 6.6 2.1 virginica
4.9 2.5 4.5 1.7 virginica
7.3 2.9 6.3 1.8 virginica
6.7 2.5 5.8 1.8 virginica
7.2 3.6 6.1 2.5 virginica
6.5 3.2 5.1 2.0 virginica
6.4 2.7 5.3 1.9 virginica
6.8 3.0 5.5 2.1 virginica
5.7 2.5 5.0 2.0 virginica
5.8 2.8 5.1 2.4 virginica
6.4 3.2 5.3 2.3 virginica
6.5 3.0 5.5 1.8 virginica
7.7 3.8 6.7 2.2 virginica
7.7 2.6 6.9 2.3 virginica
6.0 2.2 5.0 1.5 virginica
6.9 3.2 5.7 2.3 virginica
5.6 2.8 4.9 2.0 virginica
7.7 2.8 6.7 2.0 virginica
6.3 2.7 4.9 1.8 virginica
6.7 3.3 5.7 2.1 virginica
7.2 3.2 6.0 1.8 virginica
6.2 2.8 4.8 1.8 virginica
6.1 3.0 4.9 1.8 virginica
6.4 2.8 5.6 2.1 virginica
7.2 3.0 5.8 1.6 virginica
7.4 2.8 6.1 1.9 virginica
7.9 3.8 6.4 2.0 virginica
6.4 2.8 5.6 2.2 virginica
6.3 2.8 5.1 1.5 virginica
6.1 2.6 5.6 1.4 virginica
7.7 3.0 6.1 2.3 virginica
6.3 3.4 5.6 2.4 virginica
6.4 3.1 5.5 1.8 virginica
6.0 3.0 4.8 1.8 virginica
6.9 3.1 5.4 2.1 virginica
6.7 3.1 5.6 2.4 virginica
6.9 3.1 5.1 2.3 virginica
5.8 2.7 5.1 1.9 virginica
6.8 3.2 5.9 2.3 virginica
6.7 3.3 5.7 2.5 virginica
6.7 3.0 5.2 2.3 virginica
6.3 2.5 5.0 1.9 virginica
6.5 3.0 5.2 2.0 virginica
6.2 3.4 5.4 2.3 virginica
5.9 3.0 5.1 1.8 virginica

To select all columns except Species:

select(iris, -Species)
Sepal.Length Sepal.Width Petal.Length Petal.Width
5.1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 2.8 5.6 2.1
7.2 3.0 5.8 1.6
7.4 2.8 6.1 1.9
7.9 3.8 6.4 2.0
6.4 2.8 5.6 2.2
6.3 2.8 5.1 1.5
6.1 2.6 5.6 1.4
7.7 3.0 6.1 2.3
6.3 3.4 5.6 2.4
6.4 3.1 5.5 1.8
6.0 3.0 4.8 1.8
6.9 3.1 5.4 2.1
6.7 3.1 5.6 2.4
6.9 3.1 5.1 2.3
5.8 2.7 5.1 1.9
6.8 3.2 5.9 2.3
6.7 3.3 5.7 2.5
6.7 3.0 5.2 2.3
6.3 2.5 5.0 1.9
6.5 3.0 5.2 2.0
6.2 3.4 5.4 2.3
5.9 3.0 5.1 1.8


Citation

For attribution, please cite this work as

Warin (2019, May 26). Thierry Warin, PhD: [R Course] Data Wrangling with R: Reshaping and Subsetting. Retrieved from https://warin.ca/posts/rcourse-datawranglingwithr-reshaping/

BibTeX citation

@misc{warin2019[r,
  author = {Warin, Thierry},
  title = {Thierry Warin, PhD: [R Course] Data Wrangling with R: Reshaping and Subsetting},
  url = {https://warin.ca/posts/rcourse-datawranglingwithr-reshaping/},
  year = {2019}
}