# Filter data with user-specified expression

Source: `R/view.R`
`filter_data.Rd`

Filter data with user-specified expression

    filter_data(dataset, filt = "", drop = TRUE)

## Arguments

dataset

  Data frame to filter

filt

  Filter expression to apply to the specified dataset

drop

  Drop unused factor levels after filtering (default is TRUE)

## Value

Filtered data frame

## Details

Filters can be used to view a sample from a selected dataset. For example, runif(nrow(.)) > .9 could be used to sample approximately 10

## Examples

    select(diamonds, 1:3) %>% filter_data(filt = "price > max(.$price) - 100")
    #> # A tibble: 2 × 3
    #>   price carat clarity
    #>   <int> <dbl> <fct>
    #> 1 18791  2.15 SI2
    #> 2 18745  2.36 SI2
    select(diamonds, 1:3) %>% filter_data(filt = "runif(nrow(.)) > .995")
    #> # A tibble: 13 × 3
    #>    price carat clarity
    #>    <int> <dbl> <fct>
    #>  1  1895  0.51 VVS2
    #>  2  2100  0.5  VS2
    #>  3  6062  1.06 SI1
    #>  4  1087  0.42 VS2
    #>  5  7091  1.12 VVS2
    #>  6  1240  0.4  VVS2
    #>  7  4155  1    SI2
    #>  8  4641  1    VS1
    #>  9   794  0.36 SI1
    #> 10  5939  1.01 SI1
    #> 11  4405  1.15 SI2
    #> 12  1300  0.38 IF
    #> 13  5483  1.13 SI1