powered by
sweep(x, margin, margin.table(x, margin), "/")
margin
x/sum(x)
prop.table(x, margin = NULL)
x
margin.table
m <- matrix(1:4, 2) m prop.table(m, 1)
Run the code above in your browser using DataLab