Learn R Programming

xpectr (version 0.4.4)

initializeGXSFunctionAddin: Initialize gxs_function() call

Description

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)

Value

Inserts gxs_function() call for the selected function.

Returns NULL invisibly.

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.

Author

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

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.

See Also

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

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