Tsallaka zuwa abun ciki
Justice Tech School

Factors

A factor stores categories as levels. Use it for grouped data.

Example
f <- factor(c("low", "high", "mid", "low"), levels = c("low", "mid", "high"))
print(f)
print(levels(f))
print(table(f))
print(as.integer(f))

Exercise

Count categories.

(f)

Quiz Test

What does levels() return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.