sex <- factor(rbinom(1:1000, 1, 0.5), labels=c("male" , "female"));
age <- sample(1:100, 1000, rep=TRUE);
weight <- factor(rbinom(1:1000, 2, 0.6), labels=c("light", "middle", "heavy"))
by(age, sex, mean)
Run the code above in your browser using DataLab