Learn R Programming

rosetta (version 0.3.12)

varView: Variable View

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

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 rosettaVarView print(x, output = attr(x, "output"), ...)

Value

A dataframe with the variable view.

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.

Author

Gjalt-Jorn Peters & Melissa Gordon Wolf

Examples

Run this code
### 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'));


Run the code above in your browser using DataLab