Rewriting the R Markdown content and saving the file again after the environment reset.

rmd_content_updated = ““”

title: “Interactive Iris Dataset App” author: “Your Name” output: flexdashboard::flex_dashboard: orientation: columns social: menu source_code: embed runtime: shiny —

Column {data-width=300}

Controls

selectInput(
  inputId = "xvar",
  label = "Select X-axis Variable:",
  choices = names(iris)[1:4],
  selected = "Sepal.Length"
)
selectInput(
  inputId = "yvar",
  label = "Select Y-axis Variable:",
  choices = names(iris)[1:4],
  selected = "Sepal.Width"
)
selectInput(
  inputId = "colorvar",
  label = "Select Color Variable:",
  choices = c("Species", "Petal.Width", "Petal.Length"),
  selected = "Species"
)
selectInput(
  inputId = "chartType",
  label = "Select Chart Type:",
  choices = c("Scatter Plot", "Box Plot", "Density Plot"),
  selected = "Scatter Plot"
)

Column {data-width=700}

Visualization

renderPlotly({
  if (input$chartType == "Scatter Plot") {
    gg <- ggplot(iris, aes_string(x = input$xvar, y = input$yvar, color = input$colorvar)) +
      geom_point(size = 3, alpha = 0.7) +
      theme_minimal() +
      labs(title = "Iris Dataset Scatter Plot", x = input$xvar, y = input$yvar)
  } else if (input$chartType == "Box Plot") {
    gg <- ggplot(iris, aes_string(x = input$colorvar, y = input$yvar, fill = input$colorvar)) +
      geom_boxplot(alpha = 0.7) +
      theme_minimal() +
      labs(title = "Iris Dataset Box Plot", x = input$colorvar, y = input$yvar)
  } else if (input$chartType == "Density Plot") {
    gg <- ggplot(iris, aes_string(x = input$xvar, fill = input$colorvar)) +
      geom_density(alpha = 0.7) +
      theme_minimal() +
      labs(title = "Iris Dataset Density Plot", x = input$xvar)
  }
  
  ggplotly(gg)
})