Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(shiny)
- library(mlbench)
- library(ggplot2)
- library(dplyr)
- library(tidyr)
- library(class)
- library(caret)
- library(corrplot)
- library(boot)
- library(randomForest)
- library(gbm)
- ui <- fluidPage(
- titlePanel("Classification and clustering"),
- sidebarLayout(
- sidebarPanel(
- selectInput(
- 'select_predictors',
- label = 'Define predictors',
- choices = c('RI', 'Na', 'Mg', 'Al', 'Si', 'Ca', 'K', 'Ba', 'Fe'),
- selected = c('RI', 'Na', 'Mg', 'Al', 'Si', 'Ca', 'K', 'Ba', 'Fe'),
- multiple = TRUE
- )
- ),
- mainPanel(
- tabsetPanel(
- tabPanel(
- title = "tab 1",
- value = "tab1",
- verbatimTextOutput('general_linear_model')
- ),
- tabPanel(
- title = "tab 2",
- value = "tab2",
- plotOutput("cor_plot")
- ),
- tabPanel(
- title = "tab 3",
- value = "tab3",
- verbatimTextOutput('summary_glass_ds')
- )
- )
- )
- )
- )
- server <- function(input, output) {
- data(Glass)
- df_glass <- Glass[c(1:146),]
- df_glass$Type <-factor(df_glass$Type)
- output$summary_glass_ds <- renderPrint({
- summary(df_glass)
- })
- #change dataset_type for corplot
- df_num <- df_glass
- df_num$Type <- as.numeric(df_num$Type)
- df_num$Type[df_num$Type==1] <- 0
- df_num$Type[df_num$Type==2] <- 1
- cor_tab <- cor(x=df_num[])
- output$cor_plot <- renderPlot({
- corrplot(cor_tab, 'number')
- })
- output$general_linear_model <- renderPrint({
- measurevar <- "Type"
- groupvars <- input$select_predictors
- gen_lin_mod <- glm(data=df_num, as.formula(paste(measurevar, paste(groupvars, collapse=" + "), sep=" ~ ")), family = 'binomial')
- summary(gen_lin_mod)
- # paste(measurevar, paste(groupvars, collapse=" + "), sep=" ~ ")
- })
- }
- # Return a Shiny app object
- shinyApp(ui = ui, server = server)
Advertisement
Add Comment
Please, Sign In to add comment