plot_frequency {doMIsaul} | R Documentation |
ggplot
type barplots representing frequencies for each vars.cat by
partition level.ggplot
type barplots representing frequencies for each vars.cat by
partition level.
plot_frequency(
data,
partition.name,
vars.cat,
vars.cat.names = NULL,
binary.simplify = TRUE,
unclass.name = "Unclassified",
include.unclass = FALSE
)
data |
The dataset. |
partition.name |
string. Name of the partition (in data). The partition variable should be a factor. |
vars.cat |
vector of strings. variables to plot (categorical only). |
vars.cat.names |
Optional. Names for displaying the categorical
variables. (given in the same order than |
binary.simplify |
boolean. Should only the 1st level be kept for binary
variables in |
unclass.name |
If applicable, name for the unclassified observations in the partition. |
include.unclass |
boolean, should boxplot be displayed for the unclassified or should they be excluded from the plot. |
ggplot
object.
data(cancer, package = "survival")
cancer$status <- factor(cancer$status)
plot_frequency(data = cancer, partition.name = "status",
vars.cat = c("sex", "ph.ecog"))
## With unclassifieds
cancer$status.2 <- as.character(cancer$status)
cancer$status.2[sample(1:nrow(cancer), 30)] <- "Unclassif."
cancer$status.2 <- factor(cancer$status.2)
plot_frequency(data = cancer, partition.name = "status.2",
vars.cat = c("sex", "ph.ecog"),
unclass.name = "Unclassif.", include.unclass = TRUE)
## With unclassifieds (as NA)
cancer$status.3 <- cancer$status
cancer$status.3[sample(1:nrow(cancer), 30)] <- NA
plot_frequency(data = cancer, partition.name = "status.3",
vars.cat = c("sex", "ph.ecog"),
unclass.name = NA, include.unclass = TRUE)
plot_frequency(data = cancer, partition.name = "status.3",
vars.cat = c("sex", "ph.ecog", "ph.karno"),
binary.simplify = FALSE,
unclass.name = NA, include.unclass = FALSE)