R: Select Elements of a Set by Click

SelectVarDlg {DescTools} | R Documentation

## Select Elements of a Set by Click

### Description

`SelectVarDlg()` is a GUI utility, which brings up a dialog and lets the user select elements (either variables of a data.frame or levels of a factor) by point and click in a listbox. The list of selected items is written to the clipboard so that the code can afterwards easily be pasted in the source file.
`ModelDlg()` helps to compose model formulas based on the variablenames of a `data.frame`. Both functions are best used together with the package `DescToolsAddIns`, with which the functions can be assigned to a keystroke in RStudio.

### Usage

    SelectVarDlg(x, ...)

    ## Default S3 method:
    SelectVarDlg(x, useIndex = FALSE, ...)

    ## S3 method for class 'factor'
    SelectVarDlg(x, ...)

    ## S3 method for class 'data.frame'
    SelectVarDlg(x, ...)

    ModelDlg(x, ...)

### Arguments

`x` | the object containing the elements to be selected. x can be a data.frame, a factor or any other vector.
`useIndex` | defines, if the enquoted variablenames (default) or the index values should be returned.
`...` | further arguments to be passed to the default function.

### Details

When working with big data.frames with many variables it is often tedious to build subsets by typing the columnnames. Here is where the function comes in offering a "point and click" approach for selecting the interesting columns. When x is a `data.frame` the columnnames are listed, when x is a factor the according levels are listed and in all other cases the list is filled with the unique elements of x.

In the model dialog, the variablenames of the selected data.frame are listed on the right, from where they can be inserted in the model box by clicking on a button between the two boxes. Clicking on the `+` button will use + to concatenate the variablenames.

After clicking on ok, the formula `temperature ~ area + driver + delivery_min, data=d.pizza` will be inserted on the cursor position.

### Value

A comma separated list with the selected values enquoted is returned invisibly as well as written to clipboard for easy inserting the text in an editor afterwards.

### Author(s)

Andri Signorell <andri@signorell.net>

### See Also

`select.list`

### Examples

    ## Not run:
    SelectVarDlg(x = d.pizza$driver)
    SelectVarDlg(x = d.pizza, useIndex=TRUE)

    SelectVarDlg(d.pizza$driver)

    x <- replicate(10, paste(sample(LETTERS, 5, replace = TRUE), collapse=""))
    SelectVarDlg(x)

    ModelDlg(d.pizza)

    ## End(Not run)

[Package DescTools version 0.99.25 Index]