Package 'sdv'

Title: Open R Objects in 'StatDataViewer' from 'RStudio'
Description: An 'RStudio' addin that sends objects from the R session (data frames, matrices, tables, vectors, lists, time series, functions, models and more) to the 'StatDataViewer' desktop application <https://statdataviewer.com/>. Each object is converted into a plain data frame that the viewer's R data reader can display, or into a text document, written to a temporary file and opened in the running viewer. Objects can be sent with a keyboard shortcut, from the 'Addins' menu, or through View().
Authors: Xiaoguang Yan [aut, cre]
Maintainer: Xiaoguang Yan <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-10-11 13:07:59 UTC
Source: https://github.com/sashelper/sdv

Help Index


Addin: type an object name or expression to open in StatDataViewer

Description

Addin: type an object name or expression to open in StatDataViewer

Usage

sdv_addin_prompt(default = NULL, error = NULL)

Arguments

default

Text pre-filled in the prompt.

error

Optional error message shown above the prompt.


Addin: open the selection or the object under the cursor

Description

With a selection in the editor or console, the selected code is evaluated in the global environment and the result is sent to StatDataViewer. Without a selection, the object name under the cursor is used. If there is nothing usable, a prompt asks for a name or expression.

Usage

sdv_addin_view()

Clean a data frame for StatDataViewer

Description

Rebuilds x as a plain data frame whose columns only use types the viewer's R reader understands. Non-automatic row names become a leading row_names column.

Usage

sdv_clean_df(x, row_names = TRUE)

Arguments

x

A data frame.

row_names

Keep non-automatic row names as a column.

Value

A plain data.frame.


Assign a keyboard shortcut to a StatDataViewer addin

Description

Writes RStudio's keybindings/addins.json (backing up the previous file to addins.json.bak). Restart RStudio afterwards. The default Cmd+Shift+V (Ctrl+Shift+V on Windows/Linux) is not used by RStudio's built-in shortcuts.

Usage

sdv_install_shortcut(
  key = sdv_default_key(),
  binding = c("sdv_addin_view", "sdv_addin_prompt"),
  overwrite = FALSE
)

Arguments

key

Shortcut, e.g. "Cmd+Shift+V" or "Ctrl+Alt+Shift+V".

binding

"sdv_addin_view" or "sdv_addin_prompt".

overwrite

Take the key even if another addin already uses it.

Value

Path of the keybinding file, invisibly.


Check that a data frame is safe for StatDataViewer's R reader

Description

Check that a data frame is safe for StatDataViewer's R reader

Usage

sdv_is_clean(df)

Arguments

df

A data frame.

Value

TRUE, or FALSE with a "problems" attribute describing why.


Path of RStudio's addin keybinding file

Description

Path of RStudio's addin keybinding file

Usage

sdv_keybindings_path()

Value

File path (may not exist yet).


Open a file in StatDataViewer

Description

Open a file in StatDataViewer

Usage

sdv_open_file(path)

Arguments

path

File to open (.rds, .txt, .R, or any format the app reads).

Value

TRUE invisibly; errors with a hint when the app can't be found.


Convert an R object for display in StatDataViewer

Description

Generic used by sdv_view(). Methods may return a data frame (shown as a table), a character vector (shown as text) or NULL (nothing to show). The default method handles data frames, matrices, arrays, tables, time series, vectors, lists, environments, functions, models and any other object.

Usage

sdv_prepare(x, name = "object", ...)

Arguments

x

Object to convert.

name

Display name.

...

Unused.


Remove a StatDataViewer addin shortcut

Description

Remove a StatDataViewer addin shortcut

Usage

sdv_remove_shortcut(binding = c("sdv_addin_view", "sdv_addin_prompt"))

Arguments

binding

"sdv_addin_view" or "sdv_addin_prompt".


Route View() and the Environment pane's grid icon to StatDataViewer

Description

When enabled, View(x) (and clicking the table icon next to an object in RStudio's Environment pane) opens the object in StatDataViewer. Objects that are not tabular (functions, lists, environments, ...) still open in RStudio unless types = "all".

Usage

sdv_use_as_viewer(enable = TRUE, types = c("tabular", "all"), quiet = FALSE)

Arguments

enable

TRUE to enable, FALSE to restore RStudio's viewer.

types

"tabular" (data frames, matrices, arrays, tables, time series, atomic vectors) or "all".

quiet

Suppress messages.

Details

The change lasts for the current R session. To enable it automatically, add the snippet printed by this function to ⁠~/.Rprofile⁠.

Value

Whether the override is active, invisibly.


Open an R object in StatDataViewer

Description

Converts x with sdv_prepare(), writes it to a temporary file and asks StatDataViewer to open it. Data frames, matrices, arrays, tables, time series, vectors and lists open as data tables; functions, models and other objects open as text.

Usage

sdv_view(x, name = NULL, open = TRUE)

Arguments

x

Any R object.

name

Name shown in StatDataViewer. Defaults to the expression passed as x.

open

If FALSE, only write the file.

Value

The path of the written file, invisibly.

Examples

## Not run: 
sdv_view(mtcars)
sdv_view(split(iris, iris$Species), "iris_by_species")

## End(Not run)