get_var_info: Get a small data frame of the variable label and values.

View source: R/get_var_info.R

get_var_infoR Documentation

Get a small data frame of the variable label and values.

Description

get_var_info() allows you to peek at your labelled data, extracting a given column's variable labels. The intended use here is mostly "peeking" for the purpose of recoding column's in the absence of a codebook or other form of documentation. gvi() is a shortcut for this function.

Usage

get_var_info(.data, x)

gvi(...)

Arguments

.data

a data frame

x

a column within the data frame

...

optional, only to make the shortcut (gvi) work

Details

This function leans on var_label() and val_label() in the labelled package, which is a dependency for this package. The function is designed to be used in a "pipe."

Value

If the column in the data frame is not labelled, the function returns a message communicating the absence of labels. If the column in the data frame is labelled, the function returns a small data frame communicating the var_label() output (var), the (often but not always) numeric "code" coinciding with with the label (code), and the "label" attached to it (label).

Examples


library(tibble)
library(dplyr)
library(magrittr)

ess9_labelled %>% get_var_info(netusoft) # works, as intended
ess9_labelled %>% get_var_info(cntry) # works, as intended
ess9_labelled %>% get_var_info(ess9round) # barks at you; data are not labelled


stevemisc documentation built on Sept. 11, 2024, 5:23 p.m.