This is a Shiny app built on top R script to demo the use case of being able to interactively select points from a plot and have these added to a data table. We use the Plotlty library for displaying
plot as it provides functionality zoom and pan the chart, and hover on points out of the box. The app augments the functionality with interactive clicking on points to add them to a table. The table is implemented
using the Data Table library.

- The
onRenderevent handler of Plotly is coupled to thesetInputValuefunction of Shiny to handle click events on the plot on the Shiny server. - The
IDcolumn in the table has a dummy hyperlink to demo how hyperlinks may be implemented. - The table has a fourth column with a
Firebutton. When pressed, theIDof the corresponding row is shown below the table. - The table has buttons to download the data in various formats. This functionality comes out of the box with the
Buttonsextension of Data Tables. However one problem with the default implementation is that it writes out all the columns which would include the column with the Fire button. This implementation omits the 4th column from being written out. - The user may select rows in the table and click the
Deletebutton to removed them. A potentially conflict then arises between selecting a row and pressing theFirebutton. In this implementation, clicking theFirebutton will not change the selection status of the row. - There are two ways to load data into the plot:
- New random data can be generated by using a slider to select the number of points desired and clicking on
Generate dataset!. - There is a selection of saved data files in the
datadirectory that can be loaded by selecting them and pressing theLoad datasetbutton. One of the files,Points 20 no y, has been modified to remove theycolumn to show how the validation works using theshinyFeedbacklibrary.
- New random data can be generated by using a slider to select the number of points desired and clicking on
- The
shinythemeslibrary is used to skin the application.
Clone/download the repository and run it using R Studio or R script. Any required libraries will be installed when the script is run unless they have been already installed.
To run it from the command line (assuming you have R script installed and PROJECT_DIR is where the project has been installed, e.g., "./PlotlyDataTableDemo"):
R -e "shiny::runApp(PROJECT_DIR)"
The required uninstalled libraries will be downloaded and installed and when the script is running you will be given a URL that has to be copy and pasted into a web browser. Here is a small snippet of a typical output:
Loading required package: purrr
Loading required package: shinyFeedback
Loading required package: shinythemes
Loading required package: vroom
Listening on http://127.0.0.1:4859
A live demo of the app can be found at https://patwar.shinyapps.io/PlotlyDataTableDemo/.
The project is distributed under the Apache-2.0 license and the details can be found in the LICENSE file.