source("http://192.38.117.59/~linearpredictors/datafiles/readSurgery.R") ## number of the different surgeries in each NBA group cts <- table(surgery$surgtype, surgery$blocking, dnn = c("Surgery", "NBA")) addmargins(cts) ## percents within surgery type ps <- apply(cts, 1, function(x)x/sum(x)*100) t(addmargins(ps))