Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

categoriesFromLevels

Convert a factor's levels into Crunch categories.


Description

Crunch categorical variables have slightly richer metadata than R's factor variables. This function generates a list of category data from a factor's levels which can then be further manipulated in R before being imported into Crunch.

Usage

categoriesFromLevels(level_vect)

Arguments

level_vect

A character vector containing the levels of a factor. Usually obtained by running base::levels()

Value

A list with each category levels id, name, numeric_value, and missingness.

Examples

categoriesFromLevels(levels(iris$Species))

crunch

Crunch.io Data Tools

v1.28.0
LGPL (>= 3)
Authors
Greg Freedman Ellis [aut, cre], Jonathan Keane [aut], Mike Malecki [aut], Neal Richardson [aut], Gordon Shotwell [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.