varView {rosetta} | R Documentation |
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 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
" |
x |
The varView data frame to print. |
... |
Any additional arguments are passed along to
the |
Value
A dataframe with the variable view.
Author(s)
Gjalt-Jorn Peters & Melissa Gordon Wolf
Examples
### 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'));