#' # Remove all cars that are not 4 cylinder
df <- datastep(mtcars,
keep = c("mpg", "cyl", "disp"), {
if (cyl != 4)
delete()
})
df
# mpg cyl disp
# 1 22.8 4 108.0
# 2 24.4 4 146.7
# 3 22.8 4 140.8
# 4 32.4 4 78.7
# 5 30.4 4 75.7
# 6 33.9 4 71.1
# 7 21.5 4 120.1
# 8 27.3 4 79.0
# 9 26.0 4 120.3
# 10 30.4 4 95.1
# 11 21.4 4 121.0
Run the code above in your browser using DataLab