MyNixOS website logo
Description

Exploring Data with Tree Data Structures.

A simple tool allowing users to easily and dynamically explore or document a data set using a tree structure.

#muir

The muir package allows users to explore a data.frame using the tree data structure with minimal effort by simply providing the data.frame columns to be explored. In addition, the muir package allows for more targeted tree data structures to be created with specific column criteria as a method for documenting and communicating the data structure and relationships within a data set. These data tree structures can be viewed within the RStudio console, standard browers, or saved as HTML for sharing using the htmlwidgets package.

The package legerages the infrastructure provided by DiagrammeR.

Installation

Install the development version of muir from GitHub using the devtools package.

devtools::install_github('alforj/muir')

Using muir

Basic example

A basic example using muir to explore the mtcars data set showing the 'cyl' and 'carb' columns and the relationship between them. Providing the "*" qualifier (after the ":" separator) will show the top occuring values for those columns up to the limit indicated in the node.limit value. By default, the node.limit is set to 3 to curb run-away queries and unreadable trees. The value can be set explicitly when calling the muir function.

The resulting tree will be rendered starting with a level 0 node counting all rows in the data set. Each resulting level will be based on the columns provided by the user and will include nodes for each distinct value (up to the limit provided, in ascending order based on occurrences). Subsequent levels will carry the filters from previous parent nodes forward. Percentages will be provided for each node (compared to the level 0 count) by default and can be turned off if not desired.

tree.height and tree.width values control how the tree is rendered and can be adjusted to best fit trees of various depths and widths.

library(muir)
data(mtcars)
mtTree <- muir(data = mtcars, node.levels = c("cyl:*", "carb:*"), 
               tree.height = 1200, tree.width = 800)

More complicated example

Instead of just returning top counts for columns provided in node.levels, provide custom filter criteria and custom node titles in level.criteria (level.criteria could also be read in from a stored file (e.g., a crtieria.csv) as a data.frame)

The criteria data.frame below includes the column names, operators, and associated values (e.g., "cyl" <= 4), and a node title to accompany each node generated for that filter criteria. Adding a "+" suffix after the column name in the node.levels parameter will add an extra "Other" node that will aggregate all values node already provided in the level.criteria value or for values below the node.limit provided.

Additional label values can be provided with the label.vals parameter using dplyr summary functions. Custom labels for each value can be provided by adding custom text after the ":" separator.

Lastly, the direction the tree is drawn can be changed from the default left-to-right to a top-to-bottom ("TB") rendering by providing a new value for tree.dir.

criteria <- data.frame(col = c("cyl", "cyl", "carb"),
                       oper = c("<=", ">", "=="),
                       val = c(4, 4, 2),
                       title = c("Up to 4 Cylinders", "More than 4 Cylinders", "2 Carburetors"))

mtTree <- muir(data = mtcars, node.levels = c("cyl", "carb:+"),
               level.criteria = criteria,
               label.vals = c("min(wt):Min Weight", "max(wt):Max Weight"),
               tree.dir = "TB",
               tree.height = 400, tree.width = 800)

More examples

More examples can be found in the examples in the muir function

help(muir)
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