Student Details
- Alistair Grevis-James (s3644119)
Code
library(shiny)
library(ggplot2)
birds_long <- read.csv("birdDS_long.csv")
birds_wide <- read.csv("birdDS_clean.csv")
bones <- sort(colnames(birds_wide)[3:12]) # Selecting the protein columns from ds
types <- unique(birds_wide$type) # Extracting the unique values from ds$class
ui <- fluidPage(
boneH <- selectInput(inputId = "boneH", label = "Select Bone A",
choices = bones),
boneV <- selectInput(inputId = "boneV", label = "Select Bone B",
choices = bones),
checkboxGroupInput(inputId = "types",
label = "Show Types",
choices = types,
selected = types),
mainPanel(plotOutput("scatterplot"))
)
server <- function(input, output) {
output$scatterplot <- renderPlot({
birds_widex <- birds_wide[birds_wide$type %in% input$types,]
if (dim(birds_widex)[1] == 0)
{
p <- NULL
}
else if (input$boneH == input$boneV)
{
p <- ggplot(data=birds_widex, aes(x=birds_widex[input$boneH], colour=type, fill=type))
p <- p + geom_density(alpha=0.1)
}
else
{
p <- ggplot(data = birds_widex, aes(x = birds_widex[input$boneH],
y = birds_widex[input$boneV],
colour = type)) + geom_point()
}
p
})
}
shinyApp(ui = ui, server = server, options=list(height = 800)) # Run the application