plot_frequency: 'ggplot' type barplots representing frequencies for each...

Description Usage Arguments Value Examples

View source: R/plot_frequency.R

Description

ggplot type barplots representing frequencies for each vars.cat by partition level.

Usage

1
2
3
4
5
6
7
8
9
plot_frequency(
  data,
  partition.name,
  vars.cat,
  vars.cat.names = NULL,
  binary.simplify = TRUE,
  unclass.name = "Unclassified",
  include.unclass = FALSE
)

Arguments

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 vars.cat)

binary.simplify

boolean. Should only the 1st level be kept for binary variables in vars.cat?

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.

Value

ggplot object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)

LilithF/doMIsaul documentation built on Dec. 17, 2021, 12:08 a.m.