R/ufactor.R

Defines functions ufactor

Documented in ufactor

#[export]
ufactor<-function(x){
    y<-new.env()
    un<- if(is.character(x)) Rfast::Sort(unique(x)) else Rfast::sort_unique(x)
    y$values<-Rfast::Match(x,un)
    y$levels<-un
    class(y)<-"ufactor"
    lockEnvironment(y)
    lockBinding("values",y)
    lockBinding("levels",y)
    y
}

Try the Rfast package in your browser

Any scripts or data that you put into this service are public.

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.