Using Filter and Expressions

Filtering & Expressions in dataviewR

Filtering in dataviewR is done using a single powerful method:
writing a dplyr compatible expression in the filter box.

This gives you complete flexibility while keeping the logic clean and reproducible.


1. Launch dataviewR with a dataset

library(dataviewR)

dataviewer(iris)

Once the app opens, you’ll see a Filter text box where you can type any valid expression similar to dplyr::filter().

2. Filtering with Expressions

You can write any filtering condition that you would normally pass to:

dplyr::filter(...)

Basic comparisons

Sepal.Length > 5

Multiple conditions

Sepal.Length > 5 & Species == "virginica"

Using %in%

Species %in% c("setosa", "virginica")

Handling missing values

is.na(Petal.Width)

String matching

grepl("^s", Species)

When you click Submit, the expression is evaluated and the dataset updates.

Invalid expressions show a friendly error notification.

3. Re-running, clearing, or updating filters

The display updates immediately after submitting.

4. How filtering affects the generated R code

Whenever you apply a filter, the exported code reflects exactly what you typed:

iris |>
  filter(Species == "setosa" & Sepal.Length > 5) |>
  select(Sepal.Length, Sepal.Width, Species)

Filtering always appears before column selection in the generated R code.

5. Tips for Writing Expressions

Summary

In this article, you learned:
- dataviewR uses expression-based filtering system
- Expressions must be valid similar to dplyr::filter() function
- The filtered result updates on Submit
- Exported code reflects your filter exactly
- Quick filters help browsing but do not contribute to filtering logic

Expression filtering gives users full flexibility and keeps the workflow reproducible.