Skip to content

levels() function for a vector

2 messages · Chang Liu, Richard Pearson

#
Karen

levels returns the levels attribute of a variable, and a vector has no 
such attribute. This is usually used with a factor, e.g.

 > temp <- c(3, 5, 5, NA)
 > levels(factor(temp))
[1] "3" "5"

Best wishes

Richard
Chang Liu wrote: