Learn R Programming

madshapR (version 2.0.0)

drop_category: Validate and coerce any object as a non-categorical variable.

Description

Converts a vector object to a non-categorical object, typically a column in a data frame. The categories come from valid values present in the object and are suppressed from an associated data dictionary (when present).

Usage

drop_category(x)

Value

A R object.

Arguments

x

object to be coerced.

Examples

Run this code
{

library(dplyr)

###### Example 1: use madshapR_examples provided by the package
dataset <-
  madshapR_examples$`dataset_example` %>%
  mutate(prg_ever_cat = as_category(prg_ever)) %>%
  mutate(prg_ever_no_cat = drop_category(prg_ever))
  
head(dataset[c("prg_ever_cat","prg_ever_no_cat")])

###### Example 2: any data frame can be a dataset
iris_no_cat <- 
  tibble(iris) %>% mutate(Species = drop_category(Species))

head(iris_no_cat)

}

Run the code above in your browser using DataLab