ViewR

June 3, 2026 · View on GitHub

The advanced interactive data table for R. A modern, dependency-free htmlwidget that turns any data frame into a fast, beautiful, explorable grid — with column analytics, a visual query builder, and one-click reproducible code.

CRAN status Lifecycle: stable License: MIT

library(ViewR)
viewdt(mtcars)   # that's it

viewdt() is what DT::datatable() would look like if it were rebuilt today: every column header is a micro-dashboard, every filter writes runnable code, and the whole thing is a single portable HTML file with zero JavaScript dependencies. It works in the RStudio / Positron Viewer, inside Shiny, in R Markdown / Quarto, or exported for offline sharing.


Why ViewR?

DTreactableViewR viewdt()
Virtualized rendering of large data⚠️
Compact column dashboards (badges, mini-histograms, missingness)
Data Insights drawer (interactive histogram / Pareto)
Visual query builder (AND/OR, type-aware)
Reproducible code export (dplyr / base R / SQL)
Column picker + global search⚠️⚠️
Row pinning
Light / dark / auto theme⚠️⚠️
JS framework dependencyjQueryReactnone (vanilla JS)

ViewR profiles every column in R — types, missingness, histogram bins, top categories — and ships a compact metadata payload to a lean renderer, instead of recomputing statistics in the browser.


Highlights

  • 🧱 Virtualized grid — paints only what's on screen; sticky headers, sticky row index, click-to-pin rows.
  • 📊 Micro-dashboard headers — data-type badge, mini spark-histogram (numeric) or top-category bar (categorical), and a colour-coded data-completeness bar with hover tooltip.
  • 🔎 Data Insights drawer — click any header chart for a full interactive SVG histogram or Pareto bar chart, completeness meter, and Min/Mean/Median/Max.
  • Visual query builder — multi-condition AND/OR filters with type-aware operators (=, <, contains, is in, is NA, …) and a searchable multi-select for categories. Live row/column counter.
  • 〈/〉 Reproducible code — copy the exact dplyr, base R, or SQL for your current filter + visible-column state; your data's variable name is auto-substituted.
  • Column picker + global search.
  • 🎨 Light / dark / auto themes; inline variable labels (haven / ADaM ready).
  • 💾 Portable exportsave_viewdt() writes a self-contained offline HTML.

Installation

install.packages("ViewR")

Quick start

library(ViewR)

# Open the explorer
viewdt(mtcars)

# Dark theme, hide a column, custom NA placeholder
viewdt(
  iris,
  options = viewdt_options(
    theme          = "dark",
    hidden_columns = "Species",
    na_string      = "—"
  )
)

# Export a portable, offline HTML report
save_viewdt(mtcars, "mtcars.html", open = TRUE)

Inside Shiny

library(shiny); library(ViewR)
ui <- fluidPage(viewdtOutput("grid", height = "640px"))
server <- function(input, output, session)
  output$grid <- renderViewdt(viewdt(mtcars))
shinyApp(ui, server)

In R Markdown / Quarto

Just call viewdt(df) in a chunk — the widget renders inline in the knitted HTML.


The viewdt() API

viewdt(data, options = viewdt_options(), dataset_name = NULL, ...)

Everything visual is controlled by viewdt_options():

OptionDefaultWhat it does
theme"auto""auto", "light", or "dark"
show_labelsTRUEInline variable labels in headers
histogramsTRUEMini spark-histograms / category bars
missing_barsTRUEData-completeness bar per column
type_badgesTRUEData-type badges
insightsTRUESliding Data Insights drawer
query_builderTRUEMulti-condition visual filters
column_pickerTRUEShow/hide columns
code_exportTRUEdplyr / base R / SQL generator
global_searchTRUESearch-all-columns box
na_string"NA"Missing-value placeholder
hidden_columnsNULLColumns hidden on first render

See vignette("viewdt", package = "ViewR") for a full, worked walk-through with live grids.


Reproducible code, generated for you

Build a filter in the UI, click Code, and copy any of:

# dplyr
mtcars %>% filter(cyl == 6, mpg > 20) %>% select(mpg, cyl, hp)

# base R
mtcars[mtcars$cyl == 6 & mtcars$mpg > 20, c("mpg", "cyl", "hp")]
-- SQL
SELECT mpg, cyl, hp FROM mtcars WHERE cyl = 6 AND mpg > 20;

Also included: the classic ViewR() gadget

The original Shiny-gadget viewer/editor is still here for in-session work — filtering, multi-column sort, an Excel-like editor (rhandsontable), find-and-replace, and live dplyr code:

new_iris <- ViewR(iris, edit = TRUE)   # returns the edited data on Done

See ?ViewR and vignette("ViewR-intro", package = "ViewR").


License

MIT © 2024 Mahesh Divakaran