source("http://192.38.117.59/~linearpredictors/datafiles/readVitaminD.R") women <- subset(vitaminD, category == 2) ## number of women in each preference group t <- table(women$sunexp, women$country, dnn = c("Sun habits", "Country")) addmargins(t, margin = 1) ## the same table, but now as percentages rather than counts apply(t, 2, function(x)x/sum(x)*100)