columnwisePercentage | R Documentation |
Calculate the percentage (value divided by sum of values in the column) for each column
columnwisePercentage(x, default = 0, digits = 1)
x |
two dimensional numeric data structure |
default |
default value to be used if the calculated percentage is
|
digits |
number of digits (default: 1) to which the resulting
percentages are to be rounded. Set to |
# Create a random matrix of integer values
M1 <- matrix(sample(100, 12), nrow = 4, dimnames = list(LETTERS[1:4], 1:3))
# Introduce some NA
values <- as.numeric(M1)
values[sample(length(values), 3)] <- NA
M2 <- matrix(values, nrow = nrow(M1), dimnames = dimnames(M1))
M1
columnwisePercentage(M1)
M2
columnwisePercentage(M2)
columnwisePercentage(M2, default = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.