# Beautiful sankey plot — plot_sankey_single • FreesearchR
Beautiful sankey plot

Skip to contents

# Beautiful sankey plot

Source: `R/plot_sankey.R`
`plot_sankey_single.Rd`

Beautiful sankey plot

## Usage

    plot_sankey_single(data, x, y, color.group = c("x", "y"), colors = NULL, ...)

## Arguments

color.group

  set group to colour by. "x" or "y".

colors

  optinally specify colors. Give NA color, color for each level in primary group and color for each level in secondary group.

...

  passed to sankey_ready()

## Value

ggplot2 object

## Examples

    ds <- data.frame(g = sample(LETTERS[1:2], 100, TRUE), first = REDCapCAST::as_factor(sample(letters[1:4], 100, TRUE)), last = REDCapCAST::as_factor(sample(letters[1:4], 100, TRUE)))
    ds |> plot_sankey_single("first", "last")
    #> Warning: Some strata appear at multiple axes.
    #> Warning: Some strata appear at multiple axes.
    #> Warning: Some strata appear at multiple axes.

    ds |> plot_sankey_single("first", "last", color.group = "y")
    #> Warning: Some strata appear at multiple axes.
    #> Warning: Some strata appear at multiple axes.
    #> Warning: Some strata appear at multiple axes.

    data.frame(
      g = sample(LETTERS[1:2], 100, TRUE),
      first = REDCapCAST::as_factor(sample(letters[1:4], 100, TRUE)),
      last = sample(c(TRUE, FALSE, FALSE), 100, TRUE)
    ) |>
      plot_sankey_single("first", "last", color.group = "x")