visfactor: Show value-label correspondence for factor variables

View source: R/visfactor.R

visfactorR Documentation

Show value-label correspondence for factor variables

Description

This function shows you how the text labels and underlying numerical values of a given factor-type variable correspond. You can use this function in two ways: 1) in its default setting, the function returns a simple table (more accurately, a data.frame) where each row is a unique value of the factor variable. The table shows how numerical values and text labels correspond. 2) You can choose the 'detail' view, in which case the function prints out a table in which the rows are actual observations from your dataset and shows you how the factor variable's numerical values and text labels correspond in your dataset. You can choose how many rows of the dataset are printed, but the default is 15.

Usage

visfactor(variable, dataset, detail = NULL, nrows = NULL)

Arguments

variable

The variable from your dataset for which you want summary statistics. Specify it as a string (e.g., "gndr").

dataset

Your dataset (a data.frame-type object).

detail

Do you want to get the 'detail' view (TRUE/FALSE)?

nrows

How many rows do you want to get printed out if you choose the detail-view (detail=TRUE). Must be a number.

Value

A data.frame.

Examples

## Not run: 
# Loading dataset
data(ess, package = "bst290")

# Default view
visfactor(dataset = ess, variable = "gndr")

# Detailed view
visfactor(dataset = ess, variable = "gndr", detail = TRUE)

# Detailed view, with 25 instead of 15 rows printed
visfactor(dataset = ess, variable = "gndr", detail = TRUE, nrows = 25)

## End(Not run)


cknotz/bst290 documentation built on Nov. 11, 2023, 1 p.m.