Not sure what wrong I am doing here, as per the selected filter the plots are not displayed. I have given a basic filter. Please guide. I have another way to do this and that code is working, But that takes long lines of code, So I thought this is the optimized one but not working
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(readxl)
library(shiny)
library(tidyverse)
library(ggpubr)
library(ggplot2)
```
```{r}
df <- structure(list(ColA = c(39, 13, 16, 36), ColB = c("A", "A", "A",
"A"), ColC = c(97, 83, 115, 141), ColD = c(91, 127, 78, 84),
ColE = c("E", "E", "E", "E"), ColF = structure(c(1569628800,
1569715200, 1569801600, 1569888000), class = c("POSIXct",
"POSIXt"), tzone = "UTC")), row.names = c(NA, 4L), class = "data.frame")
df <- df %>% mutate_if(is.character,as.factor)
df <- as.data.frame(df)
```
Factors
===============
Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
selectInput("F1","Factor1",choices = c("",names(Filter(is.factor,df))))
output$filter2 <- renderUI({
if (input$F1 == "") {
return()
} else {
label = "Numeric Variable to compare"
selectInput("N",label,choices = c("",names(Filter(is.numeric,df))))
}
})
uiOutput("filter2")
radioButtons("T1","Tests",choices = c("t.test","Anova","Wilcoxon"),selected = NULL)
```
Column {data-width=1000}
-----------------------------------------------------------------------
### Chart A
```{r}
plotOutput("p1")
output$p1 <- renderPlot({
req(input$F1)
req(input$N)
if (!is.null(input$F1)) {
ggboxplot(df ,x = input$F1, y = input$N,
color = input$F1, palette = "jco",
add = "jitter")
}
})
```