## columns
mtcars %>%
columns(vs:carb, cyl)
mtcars %>%
columns(-am, -cyl)
# regular expression pattern
columns(iris, "^Petal") %>% head() # variables which start from 'Petal'
columns(iris, "Width$") %>% head() # variables which end with 'Width'
# move Species variable to the front.
# pattern "^." matches all variables
columns(iris, Species, "^.") %>% head()
# pattern "^.*i" means "contains 'i'"
columns(iris, "^.*i") %>% head()
# numeric indexing - all variables except Species
columns(iris, 1:4) %>% head()
# variable expansion
dims = c("Width", "Length")
columns(iris, "Petal.{dims}") %>% head()
# rows
mtcars %>%
rows(am==0) %>%
head()
# select rows with compound condition
mtcars %>%
rows(am==0 & mpg>mean(mpg))
Run the code above in your browser using DataLab