Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Incorporating Shiny into Flexdashboard for dynamic textInput with the least shiny code

$
0
0

I have built a static Flexdashboard with 10+ tabs and multiple plots in each tab.

I set a variable as a search key for each evaluated individual to knit the entire dashboard.

For example

library(flexdashboard)
library(tidyverse)
library(plotly)
library(DT)
library(cowplot)
library(lubridate)

df <- read_csv("Database.csv")
name <- regex(pattern="Smith") 

I just need to change the name "Smith" to "Virk" if I want to knit an evaluation for a person named Virk, without having to entire the whole name. It also pulls from a few other csv that may not have the entire name, hence the last name with the first letter being uppercase is the best solution for now. I don't have 2 of the same unique name for now, thank goodness.

My other tabs/plots have a generic filter using

df_radar <- cccdb %>%
  filter(str_detect(Name,name))

I have over 50+ plots and datatables using this filter system. Each html file (each evaluated individual) is about 6mb in size.

I am wondering if there is an easier way to use Shiny's textInput for dynamic change of variable "name" and renderPlot{} on my plots and datatables without having to change my entire dashboard code. For example:

library(flexdashboard)
library(tidyverse)
library(plotly)
library(DT)
library(cowplot)
library(lubridate)
library(shiny)

df <- read_csv("Database.csv")
#Replacement of "name" variable
textInput("Name", "name:")
#one of the plot
renderPlot({
name <- regex(pattern = input$Name)
df_radar <- cccdb %>%
  filter(str_detect(Name,name) %>%
ggplot(.,
aes(x=Productivity)) +
geom_bar()

df_radar

})

I was able to do that. However, the problem is, I'd have to repeat this:

name <- regex(pattern = input$Name)

for all 50+ renderPlots and renderDataTable. I was wondering if there is a simpler way. Thank you for your help!


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>