The project’s purpose is to develop an R Shiny app for stakeholders, such as realtors, to use to make effective business decisions.

Dataset Description

ui.R

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ui <- fluidPage(
  selectInput("variable", "Variable:",
              c("Bedrooms" = "bedrooms",
                "Rooms" = "rooms",
                "Baths" = "baths",
                "Garage" = "garage")),
  sidebarPanel(
    sliderInput("lotsize_value", "Lot size (in thousands of square feet):",
                min = 2.275, max = 10,
                value = 10, step=0.5),
    sliderInput("taxes_value", "Enter taxes (in thousands of dollars):",
                min = 3.891, max = 10,
                value = 10, step=0.5),
    sliderInput("livingspace_value", "Enter max living space (in thousands square feet):",
                min = .975, max = 2,
                value = 2, step=0.1),
    sliderInput("fireplaces_value", "Enter  max fireplace:",
                min = 0, max = 1,
                value = 1, step=1)
  ),
  mainPanel(plotOutput("main_plot"))
)

2. 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
library(MPV)
library(shiny)
library(ggplot2)

sales<-table.b4
names(sales)<-c("sale","taxes","baths","lotsize","livingspace","garage","rooms","bedrooms","homeage","fireplaces")
attach(sales)

server <- function(input, output) {
  output$main_plot <- renderPlot({
    lotsize_f<- input$lotsize_value
    tax_f<-input$taxes_value
    livingspace_f<- input$livingspace_value
    fireplaces_f<- input$fireplaces_value

    graph_data<- subset(sales, lotsize<=lotsize_f & taxes<=tax_f & livingspace<=livingspace_f & fireplaces<=fireplaces_f,select=c("sale","taxes","lotsize","livingspace","garage","rooms","bedrooms","homeage","fireplaces","baths"))

    Variable<-factor(graph_data[[input$variable]])
    ggplot(graph_data, aes(x=homeage, y=sale, shape=Variable, color=Variable))+geom_point(size=6)+xlab("Age of Home (in years)")
    +ylab("Sale Price of House (in thousands of dollars)")
    +ggtitle(label="Sale Price of House vs. Age of House",subtitle="Source: table.b (MPV)")+xlim(0,70)+ylim(20,50)
    +theme(axis.text=element_text(size=15), axis.title=element_text(size=15,face="bold"),plot.title = element_text(color = "black", size = 17, face = "bold"),plot.subtitle = element_text(color = "black", size=15),legend.title = element_text(color = "black", size = 15),legend.text = element_text(color = "black", size=15))
  })
}