mardi 12 janvier 2016

Randomly Creating Categorical Variables in R

How can I randomly create categorical variables in R?

Below I randomly create a variable that is composed of the values "m" and "f", which stand for male and female.

sex <- sample(letters[c(6,13)], 10000, replace=TRUE)

But how can I enter the values in words, as in "male" and "female"?




Aucun commentaire:

Enregistrer un commentaire