| Title: | Advanced Interactive Data Tables and Data Explorer |
|---|---|
| Description: | An advanced, interactive data table and data explorer for R, delivered as a modern, self-contained 'htmlwidget' with a high-performance virtualized grid. ViewR renders 'Kaggle'-style micro-dashboard column headers complete with data-type badges, mini distribution spark-histograms, and data-completeness (missingness) bars. It provides hover metadata cards, a sliding Data Insights drawer with interactive histograms and 'Pareto' category charts, a multi-condition visual query builder (AND/OR), a column visibility picker, and a reproducible code generator that emits 'dplyr', base R, and 'SQL' that matches the active filter and column state. The interface is implemented entirely in dependency-free vanilla 'JavaScript' (no 'React' or build toolchain) and works in the 'RStudio'/'Positron' Viewer, inside 'Shiny' apps, in 'R Markdown'/'Quarto', or as a portable standalone 'HTML' file. A single call to viewr() opens the explorer; the legacy 'Shiny'-gadget ViewR() editor remains available. |
| Authors: | Mahesh Divakaran [aut, cre] |
| Maintainer: | Mahesh Divakaran <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.0.0 |
| Built: | 2026-06-03 19:01:26 UTC |
| Source: | https://github.com/itsmdivakaran/viewr |
Checks which required packages are missing from the user's library and
installs them via install.packages.
install_viewr_deps(ask = TRUE)install_viewr_deps(ask = TRUE)
ask |
Logical. If |
Invisibly returns a character vector of packages that were (or needed to be) installed.
## Not run: install_viewr_deps() ## End(Not run)## Not run: install_viewr_deps() ## End(Not run)
Exports any data frame as a fully interactive, offline ViewR explorer that runs in any browser without R or an internet connection.
save_viewdt( data, file, options = viewdt_options(), selfcontained = TRUE, title = "ViewR", dataset_name = NULL, open = FALSE )save_viewdt( data, file, options = viewdt_options(), selfcontained = TRUE, title = "ViewR", dataset_name = NULL, open = FALSE )
data |
A 'data.frame' or 'tibble' to export. |
file |
Output '.html' path. |
options |
A list created by [viewdt_options()]. |
selfcontained |
Logical. If 'TRUE' (default) bundle all assets into a single file (requires pandoc); if 'FALSE', write a lightweight HTML file plus a companion '_files/' directory (recommended for large data). |
title |
Browser tab title. Default '"ViewR"'. |
dataset_name |
Variable name used in generated code. Defaults to the deparsed 'data' expression. |
open |
Logical. Open the file in a browser after saving (interactive sessions only). Default 'FALSE'. |
The output file path, invisibly.
## Not run: save_viewdt(mtcars, "mtcars.html", open = TRUE) save_viewdt(iris, "iris.html", selfcontained = FALSE) ## End(Not run)## Not run: save_viewdt(mtcars, "mtcars.html", open = TRUE) save_viewdt(iris, "iris.html", selfcontained = FALSE) ## End(Not run)
Opens a high-performance, self-contained data explorer for a data frame. 'viewdt()' profiles every column in R and renders a virtualized grid with “Kaggle”-style micro-dashboard headers (data-type badges, mini spark-histograms, and data-completeness bars), hover metadata cards, a sliding Data Insights drawer, a multi-condition visual query builder, a column-visibility picker, and a reproducible code generator (dplyr, base R, and SQL).
viewdt( data, options = viewdt_options(), dataset_name = NULL, width = NULL, height = NULL, elementId = NULL )viewdt( data, options = viewdt_options(), dataset_name = NULL, width = NULL, height = NULL, elementId = NULL )
data |
A 'data.frame' or 'tibble' to explore. |
options |
A list created by [viewdt_options()]. |
dataset_name |
Character used as the data variable name in generated code. Defaults to the deparsed 'data' expression. |
width, height
|
Optional widget dimensions; default to a full-container responsive layout. |
elementId |
Optional explicit element id. |
The interface is implemented entirely in dependency-free vanilla JavaScript (no React or build toolchain) and works in the RStudio / Positron Viewer, inside Shiny, in R Markdown / Quarto, or as a portable standalone HTML file via [save_viewdt()].
An 'htmlwidget' object.
## Not run: viewdt(mtcars) viewdt(iris, options = viewdt_options(theme = "dark", hidden_columns = "Species")) ## End(Not run)## Not run: viewdt(mtcars) viewdt(iris, options = viewdt_options(theme = "dark", hidden_columns = "Species")) ## End(Not run)
Builds the option list consumed by [viewdt()] and [save_viewdt()]. Every argument has a sensible default, so 'viewdt_options()' with no arguments returns a fully usable configuration.
viewdt_options( theme = c("auto", "light", "dark"), show_labels = TRUE, histograms = TRUE, missing_bars = TRUE, type_badges = TRUE, insights = TRUE, query_builder = TRUE, column_picker = TRUE, code_export = TRUE, global_search = TRUE, na_string = "NA", hidden_columns = NULL, page_size = 200L, hist_bins = 20L, top_n = 10L, max_cells = 5e+06 )viewdt_options( theme = c("auto", "light", "dark"), show_labels = TRUE, histograms = TRUE, missing_bars = TRUE, type_badges = TRUE, insights = TRUE, query_builder = TRUE, column_picker = TRUE, code_export = TRUE, global_search = TRUE, na_string = "NA", hidden_columns = NULL, page_size = 200L, hist_bins = 20L, top_n = 10L, max_cells = 5e+06 )
theme |
UI appearance: one of '"auto"' (default, follows the host/system colour scheme), '"light"', or '"dark"'. |
show_labels |
Logical. Display variable-label attributes (e.g. as set by haven or clinical ADaM data) inline in the column headers. Default 'TRUE'. |
histograms |
Logical. Render mini spark-histograms / category bars inside the column headers. Default 'TRUE'. |
missing_bars |
Logical. Render the data-completeness (missingness) bar at the bottom of each header. Default 'TRUE'. |
type_badges |
Logical. Show data-type badges in headers. Default 'TRUE'. |
insights |
Logical. Enable the sliding Data Insights drawer. Default 'TRUE'. |
query_builder |
Logical. Enable the multi-condition visual query builder. Default 'TRUE'. |
column_picker |
Logical. Enable the column-visibility picker. Default 'TRUE'. |
code_export |
Logical. Enable the reproducible code generator (dplyr / base R / SQL). Default 'TRUE'. |
global_search |
Logical. Enable the global search box. Default 'TRUE'. |
na_string |
Character. Placeholder shown for missing values. Default '"NA"'. |
|
Character vector of column names hidden on first render. Default 'NULL'. |
|
page_size |
Integer. Rows kept in the virtualized DOM buffer. Default '200L'. |
hist_bins |
Integer. Number of bins for numeric histograms. Default '20L'. |
top_n |
Integer. Number of categories profiled for character columns. Default '10L'. |
max_cells |
Integer. Soft safeguard; data frames with more than this many cells ('nrow * ncol') trigger a warning. Default '5e6'. |
A named list of class '"viewdt_options"'.
viewdt_options(theme = "dark", hidden_columns = c("cyl", "hp"))viewdt_options(theme = "dark", hidden_columns = c("cyl", "hp"))
Output and render functions for using [viewdt()] within Shiny applications and interactive R Markdown documents.
viewdtOutput(outputId, width = "100%", height = "600px") renderViewdt(expr, env = parent.frame(), quoted = FALSE)viewdtOutput(outputId, width = "100%", height = "600px") renderViewdt(expr, env = parent.frame(), quoted = FALSE)
outputId |
Output variable to read from. |
width, height
|
Must be valid CSS units (e.g. '"100%"') or numbers. |
expr |
An expression that generates a [viewdt()] widget. |
env |
The environment in which to evaluate 'expr'. |
quoted |
Is 'expr' a quoted expression (with 'quote()')? |
'viewdtOutput()' returns a Shiny output UI element; 'renderViewdt()' returns a Shiny render function.
Opens a feature-rich, popup-based Shiny interface for viewing, exploring, filtering, sorting, editing, and analysing R data frames. All operations are reflected in real-time as copy-pasteable dplyr code.
ViewR( data, edit = FALSE, popup = TRUE, labels = NULL, title = NULL, viewer = c("dialog", "browser", "pane"), generate_code = TRUE, theme = c("flatly", "cerulean", "cosmo", "darkly", "lumen", "paper", "readable", "sandstone", "simplex", "spacelab", "united", "yeti"), max_display = 50000L, return_data = TRUE, ... )ViewR( data, edit = FALSE, popup = TRUE, labels = NULL, title = NULL, viewer = c("dialog", "browser", "pane"), generate_code = TRUE, theme = c("flatly", "cerulean", "cosmo", "darkly", "lumen", "paper", "readable", "sandstone", "simplex", "spacelab", "united", "yeti"), max_display = 50000L, return_data = TRUE, ... )
data |
A |
edit |
Logical. Enable the Excel-like editing tab.
Default |
popup |
Logical. If |
labels |
Optional named character vector of variable labels.
Names must match column names of |
title |
Window title. Defaults to the name of |
viewer |
Where to display the interface:
|
generate_code |
Logical. Show the R Code tab. Default |
theme |
Bootstrap theme for the UI. One of
|
max_display |
Integer. Maximum rows rendered in the Data View table
(for performance). Default |
return_data |
Logical. When the user clicks Done, return the
(possibly edited) data frame. Default |
... |
Reserved for future arguments; currently ignored. |
If return_data = TRUE and the user clicked Done,
returns the modified data frame invisibly. Otherwise returns the
original data frame invisibly.
Data View - searchable, paginated DT table with optional variable-label tooltips and column-level search filters.
Sidebar Filters - add unlimited filter conditions with
operators ==, !=, >, >=, <,
<=, contains, starts with, ends with,
is NA, is not NA; combine with AND / OR logic.
Multi-column Sort - add multiple sort levels; choose ascending or descending per column.
Column Visibility - show/hide any columns via checkboxes.
Excel-like Editor (edit = TRUE) - powered by
rhandsontable; supports in-cell editing, adding rows, and
unlimited undo/redo.
Find & Replace - find literal text or regex across one or all columns with case-sensitivity and exact-match options; preview changes before applying.
Variable Info - data type, N, missing min, max, and sample values for every column.
R Code Generation - the R Code tab always shows the complete, runnable dplyr pipeline for the current state. One click copies it to the clipboard.
## Not run: ## -- Basic view ------------------------------------------------------------ ViewR(mtcars) ## -- Edit mode: returns modified data ------------------------------------- new_iris <- ViewR(iris, edit = TRUE) ## -- Custom labels + dark theme -------------------------------------------- ViewR(mtcars, labels = c(mpg = "Miles per Gallon", cyl = "Number of Cylinders", hp = "Gross Horsepower"), theme = "darkly") ## -- Open in the system browser -------------------------------------------- ViewR(iris, viewer = "browser", generate_code = TRUE) ## -- View a haven-imported dataset (labels read automatically) ------------- # df <- haven::read_sav("my_survey.sav") # ViewR(df) ## End(Not run)## Not run: ## -- Basic view ------------------------------------------------------------ ViewR(mtcars) ## -- Edit mode: returns modified data ------------------------------------- new_iris <- ViewR(iris, edit = TRUE) ## -- Custom labels + dark theme -------------------------------------------- ViewR(mtcars, labels = c(mpg = "Miles per Gallon", cyl = "Number of Cylinders", hp = "Gross Horsepower"), theme = "darkly") ## -- Open in the system browser -------------------------------------------- ViewR(iris, viewer = "browser", generate_code = TRUE) ## -- View a haven-imported dataset (labels read automatically) ------------- # df <- haven::read_sav("my_survey.sav") # ViewR(df) ## End(Not run)