diaporamaMiscDM
 
◃  Ch. 7 Intro à R  ▹
 

Les facteurs (2/2)

> x <- factor (vector("numeric",5))
> x
[1] 0 0 0 0 0
Levels: 0
> x <- factor (vector("numeric",5),levels=0:3)
> x
[1] 0 0 0 0 0
Levels: 0 1 2 3
> x <- factor (vector("numeric",5),levels=1:3)
> x
[1] <NA> <NA> <NA> <NA> <NA>
Levels: 1 2 3
> x <- factor (1:3,labels=c("a","b","c"))
> x
[1] a b c
Levels: a b c
> levels(x)
[1] "a" "b" "c"