switch_cat_repr: Switch the representation of a categorical object

View source: R/utils.R

switch_cat_reprR Documentation

Switch the representation of a categorical object

Description

Categorical data with n observations and R levels can typically be represented as two forms in R: a factor with length n, or an n by K indicator matrix with elements being 0 or 1. This function is to switch the form of a categorical object from one to the another.

Usage

switch_cat_repr(obj)

Arguments

obj

an object representing categorical data, either a factor or an indicator matrix with each row representing an observation.

Value

categorical object in the another form.


semidist documentation built on Nov. 21, 2023, 9:06 a.m.