dputSelectedAddin: Replaces selected code with its dput() output

View source: R/dput_addins.R

dputSelectedAddinR Documentation

Replaces selected code with its dput() output

Description

\Sexpr[results=rd, stage=render]{lifecycle::badge("experimental")}

RStudio Addin: Runs dput() on the selected code and inserts it instead of the selection.

See `Details` for how to set a key command.

Usage

dputSelectedAddin(selection = NULL, insert = TRUE, indentation = 0)

Arguments

selection

String of code. (Character)

E.g. "stop('This gives an expect_error test')".

N.B. Mainly intended for testing the addin programmatically.

insert

Whether to insert the expectations via rstudioapi::insertText() or return them. (Logical)

N.B. Mainly intended for testing the addin programmatically.

indentation

Indentation of the selection. (Numeric)

N.B. Mainly intended for testing the addin programmatically.

Details

How

Parses and evaluates the selected code string, applies dput() and inserts the output instead of the selection.

How to set up a key command in RStudio

After installing the package. Go to:

Tools >> Addins >> Browse Addins >> Keyboard Shortcuts.

Find "dput() Selected" and press its field under Shortcut.

Press desired key command, e.g. Alt+D.

Press Apply.

Press Execute.

Value

Inserts the output of running dput() on the selected code.

Does not return anything.

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

Other addins: assertCollectionAddin(), initializeGXSFunctionAddin(), initializeTestthatAddin(), insertExpectationsAddin(), navigateTestFileAddin(), wrapStringAddin()


xpectr documentation built on Nov. 18, 2022, 5:10 p.m.