-
Notifications
You must be signed in to change notification settings - Fork 0
/
R_Shiny.R
46 lines (36 loc) · 1.1 KB
/
R_Shiny.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Setup -------------------------------------------------------------------
setwd("~/work")
install.packages("shiny");
rawdata <- read.csv("./NYC_Housing_Data.csv")
# RShiny Visualization ----------------------------------------------------
#UI
library(shiny)
# Define UI for app that draws a histogram ----
ui <- fluidPage(
titlePanel("NYC Housing Data"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "bins",
label = "Number of bins:",
min = 1,
max = 20,
value = 100)
),
mainPanel(
plotOutput(outputId = "distPlot")
)
)
)
#Server
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- rawdata$median_rent
bins <- seq(min(x), max(x), length.out = input$bins)
hist(x, breaks = bins, col = "blue", border = "white",
xlab = "Median Rent Price",
ylab = "Number of boros",
main = "Histogram of Median Rent Prices in NYC Boros")
})
}
# Start the Server
shinyApp(ui=ui, server=server, options=list(port=8080, host="0.0.0.0"))