This helper function retrieves the original question label associated with a
variable in a data frame. If no label attribute is present, it returns the
variable name itself.
Arguments
- data
A data frame containing the variable for which the question label
is to be retrieved.
- var
The name of the variable within the data frame whose question label
is being sought. This should be a string corresponding to the column name in
data
.
Value
Returns the original question label as a string. If no label is
associated with the variable, the variable name is returned.
Details
The function checks for a label
attribute on the specified variable in the
data frame. If the label
attribute exists, it is returned as the question
label; otherwise, the name of the variable (var
) is returned.
Note
This function is used by compile
, crosstab
, and plot_popn
.