EstimationDataTemplate: Extract dataframe information for a template

View source: R/estimationdata.R

EstimationDataTemplateR Documentation

Extract dataframe information for a template

Description

Inspects the input dataframe and creates a list of lists. Each list element takes the name of the variable and contains information about the variable with a sublist. Such information includes the type of the variable (numeric or factor), and other metadata attributes such as the label of the variable, the name of the variable, question type of the variable, the dataset it originates from and others.

Usage

EstimationDataTemplate(x, outcome.name)

Arguments

x

A data.frame containing the data to be templated.

outcome.name

An optional name of the outcome variable. Should be a character(1L) string. If specified it will be set as the "outcome.name" attribute in the returned list (see below). If not specified, then the attribute will be set to NA_character_.

Value

A list of lists. The list will have an attribute called "outcome.name" which will be set to the value of the outcome.variable argument or NA_character_ if not provided. Each sublist contains information about each variable from the input data.frame with the following elements:

  • type: The type of the variable (numeric or factor)

  • label: The label of the variable

  • name: The name of the variable

  • questiontype: The question type of the variable

  • question: The question of the variable

  • dataset: The dataset of the variable

  • levels: If variable is a factor, the levels of the variable, otherwise not present

  • observed.levels: If variable is a factor, the observed levels of the variable, otherwise not present

  • has.unobserved.levels: Boolean indicating whether the variable has unobserved levels

  • ordered: If variable is a factor, whether the factor is ordered, otherwise not present

  • default.value: The default value of the variable, the minimum if numeric or the first (observed) level if factor


NumbersInternational/flipData documentation built on March 2, 2024, 10:52 a.m.