- Getting data
- Build predictive model
- Build Shiny App
Bui Dinh Ngoc
I using data from scg.sdsu.edu
data <- read.table("http://scg.sdsu.edu/wp-content/uploads/2013/09/brain_body.txt",
skip = 12,
header = TRUE)
I using Linear Regression with log function to get best fit .
library(ggplot2)
fit <- lm(Brain_Weight ~ log(Body_Weight), data = data)
predictions <- predict(fit, data)
p<-ggplot(data, aes(x = Body_Weight, y = Brain_Weight)) +
geom_point() +stat_smooth(method = "lm", col = "red")
p + geom_vline(xintercept = input$Body_Weight, colour="green",size=1 )
## Error in data.frame(xintercept = xintercept): object 'input' not found
I choose 1 slide and 1 main content layout
# ui.R
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel(" Predict brain weight over body weight"),
h3(textOutput("Brain_Weight")),
# Sidebar with a slider input for the number of bins
sidebarLayout(
sidebarPanel(
sliderInput("Body_Weight",
"Body_Weight",
min = 1,
max = 500,
value = 30)
),
# Show a plot
mainPanel(
plotOutput("distPlot")
)
)
))
<!--html_preserve-->