I'm building a flexdashboard out in an RMarkdown document, but I've run into issues with interactivity. So I've gotten a solution in shiny up and running, but the issue is that at my place of work we don't have any shiny server options out there to support the app anywhere off my local machine. So I've checked out htmlwidgets
and crosstalk
in hopes of finding what I need there, but even that has been to niche for my problem.
So specifically, what's happening is I have a function that builds a list of lists. Let's call the bigger list plots
for reference. Each list inside of list plots
has 3 elements, the first labelled p
is a plotly
line graph. The second element is an error metric element which I use to order the lists so that the plots with the highest error metric appear first in the list. The 3rd element is called type
, which basically describes the model type used for each plot built. There are 2 types, for reference I will refer to them as type1
and type2
.
Now the flexdashboard is currently laid out like so:
---
title: "Dashboard"
author: "Me"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
---
```{r global, include=FALSE}
library(ggplot2)
library(plotly)
library(htmltools)
require(htmlwidgets)
require(manipulateWidget)
theme_set(theme_classic())
source("~/directory_where_bigRun_is_stored")
# Build Plots
plots = bigRun(parameters)
# Pull out types for reference
type_vector = unlist(lapply(plots,"[", 3))
```
Column {.sidebar data-width=200}
-------------------------------------
### Filters
<form>
<input type="checkbox" name="type1" value=1>
<label for="type1"> Include type1 models</label><br>
<input type="checkbox" name="type2" value=2>
<label for="type2"> Include type2 models</label><br><br>
<input type="submit" value="Go">
</form>
```{r echo = FALSE}
tags$submit("No idea what to do here")
```
```{r eval = FALSE}
# I also tried using this package to build out checkboxes
# but that didn't work either
manipulateWidget(
{
if(length(type) == 0){
plots2 = vector(mode = 'list', length = 50)
}else{
plots2 = lapply(plots, function(x) x[x$type %in% type])
}
},
type= mwCheckboxGroup(c("type1" = 1, "type2" = 2), c(1,2)),
.updateBtn = TRUE
)
```
Row
-----------------------------------------------------------------------
### #1 Worst
```{r}
plots2[[1]][[1]]
```
### #2 Worst
```{r}
plots2[[2]][[1]]
```
So as you can see, I've tried a couple of things within the sidebar to get a checkbox that will do exactly what I want. The raw html code actually creates a useable checkbox, but I don't know how to interact with it to do the filtering I need to do on the list. Basically, I want the checkbox to filter the list plots
into a smaller list plots2
that only contains the elements chosen in the checkbox (either type1
or type2
). It doesn't seem that any htmlWidgets
will work for this given scenario since I'm not changing the plots themselves, but instead I'm changing a list of plots that will be automatically printed out to the dashboard.
Thanks in advance for any help you can offer. This has been driving me bonkers for over a week now, and I'd really like to wrap up this hurdle for the dashboard as there are still other changes I need to make to it.
For reference I've looked at these questions posted as well but am still stumped: