ViewR

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?

DT reactable ViewR viewdt()
Virtualized rendering of large data ⚠️
Kaggle-style column headers (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 dependency jQuery React none (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


Installation

# From CRAN (once published)
install.packages("ViewR")

# Development version
# install.packages("remotes")
remotes::install_github("itsmdivakaran/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():

Option Default What it does
theme "auto" "auto", "light", or "dark"
show_labels TRUE Inline variable labels in headers
histograms TRUE Mini spark-histograms / category bars
missing_bars TRUE Data-completeness bar per column
type_badges TRUE Data-type badges
insights TRUE Sliding Data Insights drawer
query_builder TRUE Multi-condition visual filters
column_picker TRUE Show/hide columns
code_export TRUE dplyr / base R / SQL generator
global_search TRUE Search-all-columns box
na_string "NA" Missing-value placeholder
hidden_columns NULL Columns 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