varView: Variable View

Description Usage Arguments Value Author(s) Examples

View source: R/varView.R

Description

This function provides an overview of the variables in a dataframe, allowing efficient inspection of the factor levels, ranges for numeric variables, and numbers of missing values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
varView(
  data,
  columns = names(data),
  varViewCols = rosetta::opts$get(varViewCols),
  varViewRownames = TRUE,
  maxLevels = 10,
  truncLevelsAt = 50,
  showLabellerWarning = rosetta::opts$get(showLabellerWarning),
  output = rosetta::opts$get("tableOutput")
)

## S3 method for class 'rosettaVarView'
print(x, output = attr(x, "output"), ...)

Arguments

data

The dataframe containing the variables to view.

columns

The columns to include.

varViewCols

The columns of the variable view.

varViewRownames

Whether to set the variable names as row names of the variable view dataframe that is returned.

maxLevels

For factors, the maximum number of levels to show.

truncLevelsAt

For factors levels, the number of characters at which to truncate.

showLabellerWarning

Whether to show a warning if labeller labels are encountered.

output

A character vector containing one or more of "console", "viewer", and one or more filenames in existing directories. If output contains viewer and RStudio is used, the variable view is shown in the RStudio viewer.

x

The varView data frame to print.

...

Any additional arguments are passed along to the print.data.frame() function.

Value

A dataframe with the variable view.

Author(s)

Gjalt-Jorn Peters & Melissa Gordon Wolf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
### The default variable view
rosetta::varView(iris);

### Only for a few variables in the dataset
rosetta::varView(iris, columns=c("Sepal.Length", "Species"));

### Set some variable and value labels using the `labelled`
### standard, which is also used by `haven`
dat <- iris;
attr(dat$Sepal.Length, "label") <- "Sepal length";
attr(dat$Sepal.Length, "labels") <-
  c('one' = 1,
    'two' = 2,
    'three' = 3);

### varView automatically recognizes and shows these, adding
### a 'label' column
rosetta::varView(dat);

### You can also specify that you only want to see some columns
### in the variable view
rosetta::varView(dat,
                 varViewCols = c('label', 'values', 'level'));

rosetta documentation built on Nov. 14, 2021, 1:06 a.m.