forked from clayholt/Group-Project-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.R
71 lines (52 loc) · 1.99 KB
/
server.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
library("httr")
library("dplyr")
library("plotly")
library("shiny")
source("app.R")
house.data <- read.csv("house_data.csv")
house.data$total_area <- house.data$sqft_above + house.data$sqft_basement
shinyServer(function(input, output) {
output$answer1 <- renderText(
return(paste("A: Average number of bathrooms in houses priced over 1 million is ", bedrooms.average))
)
output$answer2 <- renderText(
return(paste("A: Average number of bathrooms in houses priced over 1 million is ", bathrooms.average))
)
output$answer3 <- renderText(
return(paste0("A: Average price of the houses in the best condition is $", best.condition.price))
)
areaAns <- reactive({
if(input$Area == 'min') {
return(toString(filter(house.data, total_area == min(total_area)) %>%
select(price)))
}else{
return(toString(filter(house.data, total_area == max(total_area)) %>%
select(price)))
}
})
output$answer4 <- renderText(
return(paste0("A: Price of the house is $", areaAns()))
)
gradeAns <- reactive({
ans <- input$Grade
if(ans == 2){
return("There are no houses with grade 2")
}
grade.price.average <- paste0("$", toString(round(filter(house.data, grade == ans) %>%
summarise(mean = mean(price)))))
})
output$answer5 <- renderText(
return(paste0("A: Average price of the houses with the selected grade: ", gradeAns()))
)
output$answer6 <- renderText(
return(paste0("A: Average price of the houses with a waterfront: $", waterfront.price))
)
zipcodeAns <- reactive({
ans <- input$zipcode
zipcode.price.average <- paste0("$", toString(round(group_by(house.data, zipcode) %>%
summarise(mean = mean(price)))))
})
output$answer7 <- renderText(
return(paste0("A: Average price of the house in the selected zipcode: ", zipcodeAns()))
)
})