Hi Experts. With the help of member I am able to learn R shiny beyond my limits and thanks a lot for that. However I do face some problems like below. Appreciate if anyone could help me
If I run the below code, I get htmloutput(Kable function)
as per filters. But I am trying get a plot called highcharter
(already coded below) in the same output (below html output). So basically when I filter "Mill-A", there should be 2 outpluts (1 is HTML table and another is highcharter).
I am not sure which output function should I use so that both HTML and highcharter is rendered. I tried putting renderplot but not possible. It is showing an error.
Right now what I have done is, I have just included both outputs just below each other. I am thinking by doing this way also, I should get the output right? Please guide on this?
---
title: "Untitled"
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
theme: cosmo
---
```{r setup, include=FALSE}
library(flexdashboard)
library(readxl)
library(tidyverse)
library(formattable)
library(highcharter)
library(reshape)
library(shiny)
library(knitr)
library(kableExtra)
```
```{r}
Past_Maintainence <- structure(list(Mill = c("Mill-A", "Mill-B"), `Electrical Maintainence done` = structure(c(1569283200,
1569369600), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
`Instrumentation Maintainence done` = structure(c(1569369600,
1569456000), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
`Mechanical Maintainence done` = structure(c(1569456000,
1569283200), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
Performance = c(0.5, 0.6)), row.names = 1:2, class = "data.frame")
`Mill-A` <- structure(list(air_flow = c(5, 10), max_air = c(14.2, 28.4),
min_air = c(7.6, 15.2), stabality_min_coal = c(46.5, 46.5
), explosion_limit = c(25, 50), min_air_flowfall_out_limt = c(113.8,
113.8), max_coal_flow = c(93, 93), normal_coal_flow = c(84.12,
84.12), max_air_flow_erosion_limit = c(162.5, 162.5), fan_power = c(256,
251)), row.names = c(NA, -2L), class = c("tbl_df", "tbl",
"data.frame"))
```
Summary
=================
Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
selectInput("Mill1","Equipment",choices = c("All","Mill-A"),selected = "All",multiple = TRUE)
```
Row {.tabset .tabset-fade}
-----------------------------------------------------------------------
### Performance {data-width=10}
```{r}
output$combined_plot1 <- renderText({
req(input$Mill1)
table_data <- Past_Maintainence
if (input$Mill1 != "All"){
table_data <- Past_Maintainence %>% filter(Mill %in% input$Mill1)
}
table_data %>% mutate(Performance = color_bar("lightgreen")(Performance)) %>% select(everything()) %>% kable(escape = F,caption = "Title") %>% kable_styling("hover", full_width = F)
})
htmlOutput("combined_plot1")
output$combined_plot <- renderHighchart({
req(input$Mill1)
if (input$Mill1 != "All"){
plot_data <- input$Mill1
design_melt <- subset(plot_data, select = -c(max_coal_flow, normal_coal_flow))
melted <- as.data.frame(melt(design_melt, id='air_flow'))
}
hc_marker <- highchart()%>%
hc_add_series(melted, "line", hcaes(x = value, y = air_flow, group = variable))%>%
hc_add_series(`Mill-A`, "line", hcaes(x = air_flow, y = max_coal_flow), name = "max_coal_flow")%>%
hc_add_series(`Mill-A`, "line", hcaes(x = air_flow, y = normal_coal_flow), name = "normal_coal_flow")%>%
hc_add_series(`Mill-A`, "line", hcaes(x = air_flow, y = stabality_min_coal), name = "stabality_min_coal")%>%
hc_add_series(Real_time_Parameters,"point",hcaes(x=X,y=Y,group = Parameters)) %>%
hc_xAxis(min = 70, max = 250)%>%hc_yAxis(min = 15, max = 140)
print(hc_marker)
})
highchartOutput("combined_plot")
```