library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
#Import Airbnb data 
data = read.csv("~/Documents/Senior Year /ADE/FinalProject/airbnblisting.csv")

#Clean up data 
data$price = lapply(data$price, function(x) as.integer(gsub("[,$]", "", x)))

data$host_is_superhost = gsub('t', 1, data$host_is_superhost, fixed = TRUE)
data$host_is_superhost = gsub('f', 0, data$host_is_superhost, fixed = TRUE)
data$host_is_superhost = as.integer(data$host_is_superhost)

data$host_has_profile_pic = gsub('t', 1, data$host_has_profile_pic, fixed = TRUE)
data$host_has_profile_pic = gsub('f', 0, data$host_has_profile_pic, fixed = TRUE)
data$host_has_profile_pic = as.integer(data$host_has_profile_pic)

data$host_identity_verified = gsub('t', 1, data$host_identity_verified, fixed = TRUE)
data$host_identity_verified = gsub('f', 0, data$host_identity_verified, fixed = TRUE)
data$host_identity_verified = as.integer(data$host_identity_verified)

data$is_location_exact = gsub('t', 1, data$is_location_exact, fixed = TRUE)
data$is_location_exact = gsub('f', 0, data$is_location_exact, fixed = TRUE)
data$is_location_exact = as.integer(data$is_location_exact)

data$instant_bookable = gsub('t', 1, data$instant_bookable, fixed = TRUE)
data$instant_bookable = gsub('f', 0, data$instant_bookable, fixed = TRUE)
data$instant_bookable = as.integer(data$instant_bookable)

data$neighbourhood_cleansed = as.factor(data$neighbourhood_cleansed)
data$neighbourhood_group_cleansed = as.factor(data$neighbourhood_group_cleansed)
data$accommodates = as.integer(data$accommodates)
data$bathrooms = as.numeric(data$bathrooms)
data$bedrooms = as.integer(data$bedrooms)
data$beds = as.factor(data$beds)
data$bed_type = as.factor(data$bed_type)
data$price = as.integer(data$price)


  #narrrow to just Manhattan 
data.manhattan= filter(data, neighbourhood_group_cleansed == "Manhattan", room_type == "Entire home/apt", property_type == "Apartment")

reg = lm(price ~ accommodates + bathrooms + bedrooms + neighbourhood_cleansed, data=data.manhattan)

graph

library(shiny)
library(devtools)
library(predictshine)
library(RCurl)
## Loading required package: bitops
library(httr)
set_config( config( ssl_verifypeer = 0L ) )

predictshine(reg, 
             page_title = 'How much should you price your listing?', 
             variable_descriptions = c('# of people you accommodate', "# of bathrooms", '# of bedrooms','Neighborhood'),
             main = 'How much should you price your listing?', 
             xlab =  'Predicted price', 
             description = p('Based on the number of people you accommodate, the number of bathrooms, the number of bedrooms, and the neighborhood that your listing is located, this is the suggested price that you should put down'))
## -------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## -------------------------------------------------------------------------
## 
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
Shiny applications not supported in static R Markdown documents