MyNixOS website logo
Description

Navigation Menu for Pipe-Friendly Data Processing.

Provides a navigation menu to enable pipe-friendly data processing for hierarchical data structures. By activating the menu items, you can perform operations on each item while maintaining the overall structure in attributes.

navigatr

CRANstatus Codecov testcoverage R-CMD-check

navigatr provides navigation menus and input forms.

the navigation menu allows piped data processing for hierarchical data structures. By activating menu items, operations on each item can be performed while maintaining the overall structure with attributes.

The core functions of this package are as follows,

  • new_nav_menu() builds a new navigation menu.
    • activate() accesses a menu item.
  • new_nav_input() builds a new input form.
    • itemise() enters values into the form.
  • rekey() and rekey_with() renames the key of a menu item.

Installation

You can install navigatr from CRAN.

install.packages("navigatr")

You can also install the development version from GitHub.

# install.packages("devtools")
devtools::install_github("UchidaMizuki/navigatr")

Examples

library(navigatr)
library(dplyr)

Build a navigation menu

To build a new navigation menu, give new_menu() unique keys and a list of their corresponding values. The upper rows show the menu items (keys on the left, value summaries on the right). By defining pillar::obj_sum(), you can change the way the summaries are displayed.

band <- new_nav_menu(key = c("band_members", "band_instruments"),
                     value = list(band_members, band_instruments))
band
#> # ☐ band_members:     tibble [3 × 2]
#> # ☐ band_instruments: tibble [3 × 2]
#> # 
#> # Please `activate()`.

You can activate a menu item by activate(). Activating a menu item allows you to perform operations on the active item. activate() turns a navigatr_new_menu object into an navigatr_nav_item object, and deactivate() turns it back.

band <- band |>
  activate(band_members) |>
  filter(band == "Beatles")
band
#> # ☒ band_members:     tibble [2 × 2]
#> # ☐ band_instruments: tibble [3 × 2]
#> # 
#> # A tibble: 2 × 2
#>   name  band   
#>   <chr> <chr>  
#> 1 John  Beatles
#> 2 Paul  Beatles
band <- band |> 
  deactivate()
band
#> # ☐ band_members:     tibble [2 × 2]
#> # ☐ band_instruments: tibble [3 × 2]
#> # 
#> # Please `activate()`.

The rekey() function is used to change the key of an activated menu item.

band |> 
  activate(band_instruments) |> 
  rekey("new_band_instruments")
#> # ☐ band_members:         tibble [2 × 2]
#> # ☒ new_band_instruments: tibble [3 × 2]
#> # 
#> # A tibble: 3 × 2
#>   name  plays 
#>   <chr> <chr> 
#> 1 John  guitar
#> 2 Paul  bass  
#> 3 Keith guitar

You can also build a nested navigation menu. To activate the items, specify multiple variables.

bands <- new_nav_menu(key = c("key1", "key2"),
                      value = list(band, band)) # A list of menu objects
bands |> 
  activate(key1, band_instruments) |> 
  select(name)
#> # ☒ key1: nav_menu [2]
#> #   ☐ band_members:     tibble [2 × 2]
#> #   ☒ band_instruments: tibble [3 × 1]
#> # ☐ key2: nav_menu [2]
#> # 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 John 
#> 2 Paul 
#> 3 Keith

Build a input form

input <- new_nav_input(key = c("key1", "key2"))
input
#> # ✖ key1: chr [0]
#> # ✖ key2: chr [0]
#> # 
#> # Please `itemise()`.
input |> 
  itemise(key1 = "value1",
          key2 = "value2")
#> # ✔ key1: chr [1]
#> # ✔ key2: chr [1]
#> # 
#> # Please `itemise()`.
Metadata

Version

0.2.1

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