| View | R Documentation |
A drop-in replacement for utils::View(). In an interactive R session
it behaves identically to typing View() without moderndive attached,
opening the RStudio / R Console data viewer. In a non-interactive context such as an
R Markdown or Quarto document, where utils::View() typically errors,
it instead renders an interactive DT::datatable() inline so users
can still inspect the data without their document failing to render.
View(x, title = NULL, n = 1000L, full = FALSE, seed = NULL, quiet = FALSE)
x |
an R object which can be coerced to a data frame. |
title |
title for the viewer window. Defaults to the name of |
n |
maximum number of rows to show in the inline |
full |
if |
seed |
optional integer seed making the random sample reproducible.
The global random-number stream is left unchanged regardless of whether
|
quiet |
if |
For large data frames a client-side DT::datatable() is slow and warns
that the data is too big. So in non-interactive contexts, when x has more
than n rows and full = FALSE, View() shows a random sample of n
rows and emits a message saying so. This keeps "just look at the data" fast
for beginners while making the size limitation explicit. The interactive
utils::View() path is unaffected (RStudio's viewer handles large data
natively), so n / full / seed / quiet apply only to the inline DT
rendering.
In an interactive session, invisibly returns NULL (called for
the side effect of displaying x in a viewer). In a non-interactive
session, returns a DT::datatable() htmlwidget – except inside webR
(where pandoc is unavailable), where it renders a self-contained static
HTML table through the browser viewer and invisibly returns NULL.
utils::View(), DT::datatable()
## Not run:
# In an interactive R session, behaves like utils::View():
View(un_member_states_2024)
# In an R Markdown or Quarto document, renders an interactive
# DT::datatable() inline instead of erroring:
View(un_member_states_2024)
# For large data a random sample is shown by default; override with:
View(some_big_data, full = TRUE) # all rows (may be slow)
View(some_big_data, n = 500) # sample 500 rows instead of 1000
View(some_big_data, seed = 42) # reproducible random sample
View(some_big_data, quiet = TRUE) # no "random sample" message
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.