MENU

Fun & Interesting

filter R Function of dplyr Package (Example) | Extract Rows of Tibble or Data Frame | Data Subset

Statistics Globe 3,575 lượt xem 5 years ago
Video Not Working? Fix It Now

How to extract rows of a tibble or data frame with the filter function of the dplyr package in the R programming language. More details: https://statisticsglobe.com/r-filter-function-dplyr-package
R code:

data <- data.frame(x1 = 1:5, # Create example data
x2 = letters[1:5],
group = c("gr1", "gr2", "gr1", "gr3", "gr2"))
data # Print data to RStudio console

install.packages("dplyr") # Install and load dplyr
library("dplyr")

filter(data, group == "gr2") # Subset data with filter function

Comment