Mohammad Ullah
01/29/2018
In this presentation, I am going to explore the functionality of the shiny app. The app does some data analysis upon users command on mtcars data set. It contains two tabpanels.
In this first panel, it asks the user to choose three variables to make a plot with a linear regression line.
In the second panel, a comparison between two prediction model (rpart and random forest) is implemented.
app link: https://moeensaiket.shinyapps.io/Playwithmtcarsdata/ code link: https://github.com/mohammadullah/Shiny-App-/
cars1 <- mtcars
cars1$cyl <- as.factor(cars1$cyl)
cars1$vs <- as.factor(cars1$vs)
cars1$am <- as.factor(cars1$am)
cars1$gear <- as.factor(cars1$gear)
selecteddata <- reactive({
cars1[, c(input$var1, input$var2, input$var3)]
})
output$plot1 <- renderPlot({
df1 <- selecteddata()
p <- ggplot(df1, aes(x = df1[,1], y = df1[,2], color = df1[,3]))
p <- p + geom_point(size = 5) + geom_smooth(method = "lm")
p <- p + labs(x = names(df1)[1], y = names(df1)[2], color = names(df1)[3])
p
})
library(ggplot2)
cars1 <- mtcars[, c("mpg", "hp", "cyl")]
cars1$cyl <- as.factor(cars1$cyl)
p <- ggplot(cars1, aes(x = cars1[,1], y = cars1[,2],
color = cars1[,3]))
p <- p + geom_point(size = 5) + geom_smooth(method = "lm")
p <- p + labs(x = names(cars1)[1], y = names(cars1)[2],
color = names(cars1)[3])
p
Use