Hi Friends,
Please help with below.
As the value of input$Val changes the reactive grp_data() changes.
Is it possible to capture those changes in grp_data() and store them based on input$Val for comparison later.
library(shiny)
library(tidyverse)
m1<-rnorm(20,100,sd=20)
m2<-rnorm(20,120,sd=40)
m3<-rnorm(20,140,sd=60)
data<-data.frame(m1,m2,m3)
ui<-fluidPage(
sliderInput('Val',"COV limit for X",min=0.3, max=0.8,value=0.5,step=0.1),
tableOutput("table1")
)
server<-function(input,output,session)
{
grp_data <- reactive({
t1<-data %>%
rowwise() %>%
mutate(COV_3M = sd(across(m1:m3))/rowMeans(across(m1:m3)),
XYZ_3M = if_else(COV_3M < input$Val, "X","Y")) %>%
group_by(XYZ_3M) %>%
tally()
})
output$table1 <-renderTable( grp_data())
}
shinyApp(ui=ui,server=server)