MyNixOS website logo
Description

Create Dependency Wheels and Sankey Diagrams.

By binding R functions and the 'Highcharts' <http://www.highcharts.com/> charting library, 'sankeywheel' package provides a simple way to draw dependency wheels and sankey diagrams.

'sankeywheel': Create Dependency Wheels and Sankey Diagrams

Dependency wheels and sankey diagrams can be drawn by many R Packages, such as circlize, networkD3, and ggalluvial. These packages are very powerful and easy to use, so why bother to write another duplicate package? As we can see, there are some relationships exist between dependency wheels and sankey diagrams. So why not combined these two types of charts into one R function. At the same time, it would be great to add a little interactivity to the graph. 'Highcharts', a commercial javascript charting library, can help me realize these ideas. By binding R functions and the 'Highcharts' charting library, 'sankeywheel' package provides a simple way to draw dependency wheels and sankey diagrams.

First, you can install it from CRAN or GitHub:

devtools::install_github('czxa/sankeywheel', build_vignettes = TRUE)
# or just use git
devtools::install_git("https://github.com/czxa/sankeywheel.git", build_vignettes = TRUE)

# CRAN
install.packages("sankeywheel")

Basic Usages

First, load sankeywheel package:

library(sankeywheel)
#> Highcharts (www.highcharts.com) is a Highsoft software product which is
#> not free for commercial and governmental use

There is a demo dataset built in this R packages.

sankeydf is a tibble data frame with 46 rows and 3 variables:

DT::datatable(sankeydf)

To draw dependency wheels and sankey diagrams, you need there vector, two character vectors and one numeric vector: from, to and weight.

For dependency wheels:

sankeywheel(from = sankeydf$from,
            to = sankeydf$to,
            weight = sankeydf$weight,
            type = "dependencywheel", 
            width = "100%")

For sankey diagrams:

sankeywheel(from = sankeydf$from,
            to = sankeydf$to,
            weight = sankeydf$weight,
            type = "sankey", 
            width = "100%")

Theme parameter

I hate complex codes, so I built some themes in this package. Just change theme parameter, you can render charts in different apperances.

If there are multiple charts created by this package in a RMarkdown document, use topic parameters carefully, because these charts may interfere with each other.

The default theme is sandsignika. There are other eight theme you can choose: darkgreen/darkblue/avocado/darkunica/gray/gridlight/grid/sunset:

library(manipulateWidget)
combineWidgets(
  sankeywheel(from = sankeydf$from,
            to = sankeydf$to,
            weight = sankeydf$weight,
            type = "sankey", 
            width = "100%",
            theme = "sunset", 
            title = "SUNSET"),
  sankeywheel(from = sankeydf$from,
            to = sankeydf$to,
            weight = sankeydf$weight,
            type = "dependencywheel", 
            width = "100%", 
            theme = "sunset", 
            title = "SUNSET"),
  byrow = TRUE, ncol = 2, width = "100%", height = "300px"
)

Other parameters

Here is a complete example:

sankeywheel(from = sankeydf$from,
            to = sankeydf$to,
            weight = sankeydf$weight,
            type = "dependencywheel", 
            seriesName = "Random data: ",
            width = "100%", 
            height = "400px",
            theme = "sunset", 
            title = "SUNSET",
            titleAlign = "center",
            titleSize = "18px",
            titleColor = "black",
            subtitle = "czxa.top",
            subtitleAlign = "center",
            subtitleSize = "14px",
            subtitleColor = "black")

Use it in ‘RMarkdown’ and ‘Shiny’ Apps

Here is a very simple ‘shiny’ example:

dir <- system.file("examples", "sankeywheel", package = "sankeywheel")
setwd(dir)
shiny::shinyAppDir(".")

Licence

sankeywheel has a dependency on Highcharts, a commercial JavaScript charting library. Highcharts offers both a commercial license as well as a free non-commercial license. Please review the licensing options and terms before using this software, as the sankeywheel license neither provides nor implies a license for Highcharts.

Highcharts (http://highcharts.com) is a Highsoft product which is not free for commercial and Governmental use.

Acknowledgements


License

MIT © czxa.top.

Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows