Currently, if there is only a single grouping variable, the plotting and conversion are treated as if no groups exist. This is erroneous because if the user specifies a group in the incidence call, it should be respected.
This PR will fix #84 and this behavior in three ways:
as.data.frame() will return the column name instead of counts and will add a groups column when long = TRUE.
plot() will respect single groups
plot() will inform users if there were colors not used
library("incidence")
library("ggplot2")
i <- incidence(rpois(100, 5), groups = rep("look!", 100))
my_colors <- c("at" = "blue", "this" = "pink", "look!" = "purple")
plot(i, color = my_colors)
#> 2 colors were not used: "at" = "blue", "this" = "pink"
# From issue #84
plot(i) + scale_fill_manual(name = "Hey!", values = my_colors)
#> Scale for 'fill' is already present. Adding another scale for 'fill',
#> which will replace the existing scale.
Currently, if there is only a single grouping variable, the plotting and conversion are treated as if no groups exist. This is erroneous because if the user specifies a group in the incidence call, it should be respected.
This PR will fix #84 and this behavior in three ways:
as.data.frame()
will return the column name instead ofcounts
and will add agroups
column whenlong = TRUE
.plot()
will respect single groupsplot()
will inform users if there were colors not usedCreated on 2018-12-07 by the reprex package (v0.2.1)
I still need to write tests for this, but the basic machinery is there. Thanks again to @pbkeating for pointing this out!