Psidom Xiaoyun Yang
July 25 2015
This is an introduction presentation to a house pricing App, which helps people to locate the most economic houses around their working places.
The app uses a mini database which simulates the houses prices and locations. The calculation model involves the original price and the corresponding transportation fees due to commuting between working places and houses.
The mini database contain the house information which is highly simplified to just present an idea. In the mini database, x and y are the locations while the price and cost represent the original price of the house and the final cost.
x <<- c(1, 3, 9)
y <<- c(8, 2, 7)
price <<- c(360, 340, 400)
transportFee <<- 0.5 # unit $/mile
df <- as.data.frame(cbind(x = x, y = y, price = price, cost = price))
df
x y price cost
1 1 8 360 360
2 3 2 340 340
3 9 7 400 400
Users of this app will have to input the location of their working places, and then the app will calculate the total monthly cost of each house(the rent plus the transportation fee).
Here is how the calculation is done. Step one, calculate the distance and update the data base; step two, calculate the total cost and update the data base.
df$Distance <- sqrt((df$x-wPlace$V1)^2 + (df$y-wPlace$V2)^2)
df$cost <- price + df$Distance * transportFee * 22
The ggplot is used to help users make the decision. Based on the data base, a mini map is drawn to show the location of both the houses and working place. And the second click of the go button enlarges the icon which stands for the most economic house. Here is how the visualization is achieved in server.R.
p <- ggplot(df, aes(x, y, label = priceTag)) + xlim(0, 10) + ylim(0, 10) + geom_point(shape = 15, cex = 5, col = 'green') + geom_text(vjust = -0.8) + ggtitle("Houses and working place mapping")
p <- p + geom_point(data = wPlace, aes(V1, V2), shape = 11, col = 'red', cex = 8)
p <- p + geom_segment(data = wPlace, aes(xend = V1, yend = V2), col = 'blue', lwd = 1.5, lty = 5)