fc_split {flowchart}R Documentation

fc_split

Description

This function allows to split the flowchart in function of the categories of a column of the database. It will generate as many boxes as categories has the column showing in each one the frequency of each category. It will additionally group the database per this column.

Usage

fc_split(
  object,
  var = NULL,
  N = NULL,
  label = NULL,
  text_pattern = "{label}\n {n} ({perc}%)",
  sel_group = NULL,
  na.rm = FALSE,
  show_zero = FALSE,
  round_digits = 2,
  just = "center",
  text_color = "black",
  text_fs = 8,
  bg_fill = "white",
  border_color = "black"
)

Arguments

object

fc object that we want to split.

var

variable column of the database from which it will be splitted.

N

Number of rows after the split in case 'var' is NULL.

label

Vector of characters with the label of each category in order. It has to have as many elements as categories has the column. By default, it will put the labels of the categories.

text_pattern

Structure that will have the text in each of the boxes. It recognizes label, n, N and perc within brackets. For default it is "{label}\n {n} ({perc}%)".

sel_group

Specify if the splitting has to be done only by one of the previous groups. By default is NULL.

na.rm

logical. Should missing values of the grouping variable be removed? Default is FALSE.

show_zero

logical. Should the levels of the grouping variable that don't have an event be shown? Default is FALSE.

round_digits

Number of digits to round percentages. It is 2 by default.

just

Justification for the text: left, center or right. Default is center.

text_color

Color of the text. It is black by default.

text_fs

Font size of the text. It is 8 by default.

bg_fill

Box background color. It is white by default.

border_color

Box border color. It is black by default.

Value

List with the dataset grouped by the splitting variable and the flowchart parameters with the resulting split.

Examples

clinic_patient |>
  dplyr::filter(!is.na(group)) |>
  as_fc(label = "Patients included") |>
  fc_split(group) |>
  fc_draw()


[Package flowchart version 0.3.0 Index]