mydata <- kitems::kitems(id = "mydata")Introduction to kitems
Motivations
When working on a R Shiny project that performs operations based on tabular data, whether it is for data analysis or data visualization, the first milestone in the project is to enable standard data processing.
Say the purpose of the project is to build a task manager and deliver a dashboard to follow its KPIs.
Before being able to work on the dashboard itself, it will require to write code to implement the baseline of the project:
- a tabular data object (most probably a data.frame) to manage the task’s attributes (date, description, owner…)
- a table view to display the tasks to the users
- inputs to allow data filtering (ex. current year)
- buttons to perform standard operations like create a task, update or delete existing ones
- forms and dialogs to capture user inputs
- functions to manage those operations in the background
- functions to ensure data persistence, quality and governance.
Now say that another dashboard project is related to weather observations.
A data frame of these observations is needed, a table view, buttons & functions to perform standard operations and manage everything in the background…
In many cases, it involves to write code that handles the same set of operations but for different objects, which makes this code hard to reuse in another project.
The purpose of kitems is to wrap those standard operations into a package that is not dependent on the type of item – something that is part of a list or group of things – to manage.
So that developers can focus on the specific capabilities of their project.
Shiny module
The package motivation is deeply correlated with the development of Shiny applications, so that it has been quite obvious that the best approach would be to deliver a module.
To start the module server, just call the kitems() function from the app server:
Note
The path to the data is defined with the
R_KITEMS_PATHenvironment variable.
You should either declare it in the .Renviron file or set it before calling the module:Sys.setenv("R_KITEMS_PATH" = "./")
Components to interact with the module server can be integrated inside the UI of your app.
For example, the item_widget() function will output the item table:
kitems::item_widget(id = "mydata")See the shiny-module article to get more information about the module.
Learning path
Because the package is not just a set of functions, it has some concepts that have been defined either as starting points or after deep explorations & convergence.
As it may be confusing where to start, the order of the articles is a proposal of a learning path to guide you through the documentation.
See articles’ index to follow this path.