initializeGXSFunctionAddin: Initialize 'gxs_function()' call

View source: R/initialize_gxs_function_addin.R

initializeGXSFunctionAddinR Documentation

Initialize gxs_function() call

Description

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

Initializes the gxs_function() call with the arguments and default values of the selected function.

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

Usage

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

Arguments

selection

Name of function to test with gxs_function(). (Character)

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

insert

Whether to insert the code 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 within the parent environment. When the output is a function, it extracts the formals (arguments and default values) and creates the initial `args_values` for gxs_function(). When the output is not a function, it throws an error.

How to set up a key command in RStudio

After installing the package. Go to:

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

Find "Initialize gxs_function()" and press its field under Shortcut.

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

Press Apply.

Press Execute.

Value

Inserts gxs_function() call for the selected function.

Returns NULL invisibly.

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

Other expectation generators: gxs_function(), gxs_selection(), insertExpectationsAddin()

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


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