Description Usage Arguments Examples
Standardise a summary to sum to one.
1 | standardise(x, margin = integer())
|
x |
a condensed summary. Must have |
margin |
margins to standardise along. If |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | b1 <- condense(bin(movies$year, 1))
d1 <- smooth(b1, 2, type = "reg")
if (require("ggplot2")) {
autoplot(b1)
autoplot(d1)
# Note change in x-axis limits
autoplot(standardise(d1))
}
# Can also standardise a dimension at a time
b2 <- with(movies, condense(bin(year, 2), bin(length, 10)))
b2 <- peel(b2, central = TRUE)
if (require("ggplot2")) {
autoplot(b2)
autoplot(standardise(b2)) # note legend
autoplot(standardise(b2, "year")) # each row sums to 1
autoplot(standardise(b2, "length")) # each col sums to 1
base <- ggplot(b2, aes(length, .count)) +
geom_line(aes(group = year, colour = year))
base
base %+% standardise(b2) # Just affects y axis labels
base %+% standardise(b2, "year") # Makes year comparable
base %+% standardise(b2, "length") # Meaningless for this display
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.