0% found this document useful (0 votes)
6 views3 pages

Shiny Dashboard Iris Code

This document provides code for a Shiny dashboard that visualizes the Iris dataset. It includes a user interface with options to select variables for the X and Y axes and displays a scatter plot of the selected variables. The dashboard also features a settings page for additional configurations.

Uploaded by

dsmoni022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Shiny Dashboard Iris Code

This document provides code for a Shiny dashboard that visualizes the Iris dataset. It includes a user interface with options to select variables for the X and Y axes and displays a scatter plot of the selected variables. The dashboard also features a settings page for additional configurations.

Uploaded by

dsmoni022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

R Shiny Dashboard with Iris Dataset Visualization

Code:

# Load required libraries

library(shiny)

library(shinydashboard)

# UI

ui <- dashboardPage(

dashboardHeader(title = "Shiny Dashboard with Iris Plot"),

dashboardSidebar(

sidebarMenu(

menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),

menuItem("Settings", tabName = "settings", icon = icon("cogs"))

),

dashboardBody(

tabItems(

tabItem(tabName = "dashboard",

fluidRow(

box(title = "Variable Selection", width = 4, status = "info", solidHeader = TRUE,

selectInput("xvar", "Select X-axis Variable", choices = names(iris)[1:4], selected =

"Sepal.Length"),
selectInput("yvar", "Select Y-axis Variable", choices = names(iris)[1:4], selected =

"Sepal.Width")

),

box(title = "Iris Scatter Plot", width = 8, status = "primary", solidHeader = TRUE,

plotOutput("irisPlot", height = 400)

),

tabItem(tabName = "settings",

h2("Settings Page"),

p("You can add settings here.")

# Server

server <- function(input, output) {

output$irisPlot <- renderPlot({

x <- iris[[input$xvar]]

y <- iris[[input$yvar]]

plot(x, y,

col = iris$Species,

pch = 19,

xlab = input$xvar,

ylab = input$yvar,

main = paste("Iris Dataset:", input$xvar, "vs", input$yvar))


legend("topright", legend = levels(iris$Species), col = 1:3, pch = 19)

})

# Run the app

shinyApp(ui = ui, server = server)

You might also like