The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

ViewR ViewR hex sticker

CRAN status Lifecycle: stable License: MIT

ViewR is a single-function R package that opens a feature-rich, popup-based Shiny interface for interactively viewing, filtering, sorting, editing, and analysing any data frame – with every operation reflected in real-time as copy-pasteable dplyr code.


Features


Installation

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

# Development version from GitHub:
# install.packages("remotes")
remotes::install_github("itsmdivakaran/ViewR")

Install all optional dependencies at once:

ViewR::install_viewr_deps()

Quick Start

library(ViewR)

# Basic viewer -- popup dialog
ViewR(mtcars)

# Edit mode: returns modified data frame when you click Done
new_iris <- ViewR(iris, edit = TRUE)

# Custom variable 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")

# Works with haven-imported SPSS/Stata files (labels read automatically)
# df <- haven::read_sav("my_survey.sav")
# ViewR(df)

Function Signature

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
)
Argument Default Description
data A data.frame or tibble
edit FALSE Enable Excel-like editing tab
popup TRUE Open as popup dialog
labels NULL Named vector of variable labels
title auto Window title
viewer "dialog" "dialog", "browser", or "pane"
generate_code TRUE Show the R Code tab
theme "flatly" Bootstrap/shinythemes theme
max_display 50000 Max rows rendered (performance cap)
return_data TRUE Return (edited) data on Done

Generated Code Example

After applying filters and a sort in the UI, the R Code tab shows:

library(dplyr)

mtcars_result <- mtcars |>
  filter(
    `cyl` == "6" &
    `hp` >= 110
  ) |>
  arrange(`mpg`)

UI Overview

+-----------------------------------------------------+
| [=] ViewR -- mtcars         [rows/cols info] [Done] |
+------------------+----------------------------------+
| FILTERS  [+ add] | [Data] [Edit] [F&R] [Info] [Code]|
|                  |                                  |
| SORT     [+ add] |   Searchable, paginated DT table |
|                  |                                  |
| COLUMNS          |   (or Edit / Find-Replace /      |
|  [x] mpg         |    Variable Info / R Code tab)   |
|  [x] cyl         |                                  |
|  [ ] disp        |                                  |
|                  |                                  |
| DISPLAY          |                                  |
|  Rows per page   |                                  |
+------------------+----------------------------------+

Dependencies

Required (installed automatically): shiny, miniUI, DT, rhandsontable, shinyjs, shinythemes, htmltools, jsonlite

Suggested (for specific features): haven (variable labels from .sav/.dta files), dplyr (generated code), tibble (tibble input)


License

MIT (c) 2024 Mahesh Divakaran

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.