Get startedGet started for free

Excluding observations

Often your data includes outliers or other observations which you wish to remove before further analysis. Or perhaps you simply wish to work with some subset of your data.

In the learning2014 data the variable 'points' denotes the students exam points in a statistics course exam. If the student did not attend an exam, the value of 'points' will be zero. We will remove these observations from the data.

This exercise is part of the course

Helsinki Open Data Science

View Course

Exercise instructions

  • Access the dplyr library
  • As an example, create object male_students by selecting the male students from learning2014
  • Override learning2014 and select rows where the 'points' variable is greater than zero.
  • If you do not remember how logical comparison works in R, see the 'Logical comparison' exercise from the course 'R short and sweet'.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# learning2014 is available

# access the dplyr library
library(dplyr)

# select male students
male_students <- filter(learning2014, gender == "M")

# select rows where points is greater than zero
learning2014 <- 
Edit and Run Code