Round | R Documentation |
Rounds a numeric vector constrained to sum to a target
value.
Round(x, target = NULL)
x |
numeric values |
target |
desired sum of |
roundr
; round_to
pcts <- data.frame(
pct1 = c(33.3, 21.5, 45.51),
pct2 = c(33.3, 33.3, 33.3)
)
## base round
colSums(mapply(round, pcts))
## round to target
colSums(mapply(Round, pcts, 100))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.