knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

navigatr

CRAN status Codecov test coverage 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,

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 create a new navigation menu, give new_menu() unique keys and a list of their corresponding values. The top rows show the menu items (keys on the left, value summaries on the right). The description argument allows you to add descriptions to the menu items (optional).

band <- new_nav_menu(
  key = c("band_members", "band_instruments"),
  value = list(
    band_members, 
    band_instruments
  ),
  description = c(
    "A data frame of band members",
    "A data frame of band instruments"
  )
)
band

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 <- band |> 
  deactivate()
band

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

band |> 
  activate(band_instruments) |> 
  rekey("new_band_instruments")

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)

Build a input form

input <- new_nav_input(
  key = c("key1", "key2")
)
input
input |> 
  itemise(
    key1 = "value1",
    key2 = "value2"
  )


UchidaMizuki/navigatr documentation built on June 14, 2025, 9:59 p.m.