library(shiny)
## Warning: package 'shiny' was built under R version 4.2.3
library(shinydashboard)
## Warning: package 'shinydashboard' was built under R version 4.2.3
## 
## Attaching package: 'shinydashboard'
## The following object is masked from 'package:graphics':
## 
##     box
library(readxl)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(RColorBrewer)
data <- read_excel("C:/Users/91990/Downloads/Immunotherapy (1).xlsx")
ui <- fluidPage(
    titlePanel("Abhi Neil Karani 20BDS0362 TH DA 2 IMMUNOTHERAPY"),
    sidebarLayout(
        sidebarPanel(
            sliderInput(
                inputId = "Type",
                label = "select Type of wart",
                min = min(data$Type),
                max = max(data$Type),
                value = min(data$Type)
            ),
            selectInput(
                inputId = "sex",
                label = "select gender",
                choices = unique(data$sex),
                selected = "1"
            ),
            plotOutput(outputId = "bargraph2")
        ),
        mainPanel(
            plotOutput(outputId = "scatterplot"),
            plotOutput(outputId = "bargraph1")
        )
    )
)

server <- function(input, output) {
    # scatter plot
    output$scatterplot <- renderPlot({
        data %>%
            filter(Type == input$Type, sex == input$sex) %>%
            ggplot(aes(x = Number_of_Warts, y = age, size = Area, color = Type)) +
            geom_point() +
            scale_x_log10() +
            scale_color_gradient(low = "blue", high = "red") +
            labs(
                x = "number of warts", y = "age",
                title = paste0(
                    "Scatter plot for number of warts and age (", input$Type, ",", input$sex, ")"
                )
            )
    })
    output$bargraph1 <- renderPlot({
        data %>%
            filter(Type == input$Type, sex == input$sex) %>%
            group_by(age) %>%
            summarise(mean_time = mean(Time)) %>%
            arrange(desc(mean_time)) %>%
            top_n(10) %>%
            ggplot(aes(x = age, y = mean_time, fill = age)) +
            scale_fill_gradient(low = "#3434a4db", high = "#992559") +
            geom_bar(stat = "identity") +
            labs(
                x = "age", y = "mean_time",
                title = paste0(
                    "Bar graph for age and time (",
                    input$Type, ",", input$sex, ")"
                )
            )
    })
    output$bargraph2 <- renderPlot({
        data %>%
            filter(Type == input$Type, sex == input$sex) %>%
            group_by(Number_of_Warts) %>%
            summarise(mean_area = mean(Area)) %>%
            arrange(desc(mean_area)) %>%
            top_n(10) %>%
            ggplot(aes(x = Number_of_Warts, y = mean_area, fill = Number_of_Warts)) +
            scale_fill_gradient(low = "#3434a4db", high = "#992559") +
            geom_bar(stat = "identity") +
            labs(
                x = "Number_of_Warts", y = "mean_area",
                title = paste0(
                    "Bar graph for Number_of_Warts and Area (",
                    input$Type, ",", input$sex, ")"
                )
            )
    })
}

shinyApp(ui, server)
Shiny applications not supported in static R Markdown documents

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.