Skip to content
Prev 66239 / 398503 Next

Count missing variables in dataset

On Mon, 21 Mar 2005 12:07:16 +0100 Jan Sabee wrote:

            
You just need to set up the variables properly. If you just say:

R> x <- factor(sample(LETTERS[1:3], 5, replace = TRUE))
R> summary(x)
A B C 
1 2 2 

R will assume that the only levels available are A-C. But if you tell R

R> x <- factor(x, levels = LETTERS[1:5])
R> summary(x)
A B C D E 
1 2 2 0 0 

it will do what you want. Just provide the full choice set as levels to
the corresponding variables.
Z