#calculate probabilities
x <- sample(c("a","b","c","d","e"), 10, replace=TRUE)
classprob(x)
#labels the probabilities
levels(as.factor(x))
#to see levels which aren't represented in the vector
x <- as.factor(c("a","a","a","b","b","c"))
levels(x)
#now remove the "c"
x <- x[1:5]
#but "c" is still a level
levels(x)
#and the probability is calculated for it
classprob(x)
Run the code above in your browser using DataLab