First, let’s load the data from the git account:

library(downloader) 
url <- "https://raw.githubusercontent.com/Kolpashnikova/project2/master/pricesscrapedcopy.csv"
filename <- basename(url)
download(url, destfile=filename)
pr <- read.csv(filename,header = T)
pr$date2<-as.Date(pr$date2)

Next, let’s see if we can scatter an association between date/time and average price.

require(ggplot2)

ggplot(pr, aes(x = date2, y = ch))+ geom_point(aes(color=factor(type_vec)))+ geom_smooth(method = "lm", se = TRUE)

The graph above shows results for all types of properties including the average overall, which needs to be remedied. We can create subsets of the data for all types of properties.

sub_all <- subset(pr, type_vec=="All Properties")
sub_1 <- subset(pr, type_vec=="1 Bedroom Properties")
sub_2 <- subset(pr, type_vec=="2 Bedroom Properties")
sub_3 <- subset(pr, type_vec=="3 Bedroom Properties")
sub_4 <- subset(pr, type_vec=="4 Bedroom Properties")
sub_5 <- subset(pr, type_vec=="5 Bedroom Properties")
sub_6 <- subset(pr, type_vec=="6 Bedroom Properties")
sub_7 <- subset(pr, type_vec=="7 Bedroom Properties")
sub_8 <- subset(pr, type_vec=="8 Bedroom Properties")
sub_9 <- subset(pr, type_vec=="9 Bedroom Properties")
sub_10 <- subset(pr, type_vec=="10 Bedroom Properties")
sub_11 <- subset(pr, type_vec=="11 Bedroom Properties")
sub_12 <- subset(pr, type_vec=="12 Bedroom Properties")
sub_13 <- subset(pr, type_vec=="13 Bedroom Properties")

We can also write a function for making graphs to avoid repetitions:

list<-rownames(as.matrix(table(pr$type_vec)))
myf3<-function(sub){
    pl<-ggplot(sub, aes(x = date2, y = ch))+ geom_point(aes(color=factor(zipcode)))+ geom_smooth(method = "lm", se = TRUE)
    return(pl)
}

For all properties, the trend over time will look the following way (color-coded by zip code):

par(mfrow=c(1,1))
myf3(sub_all)

1 Bedroom Properties:

myf3(sub_1)

2 Bedroom Properties:

myf3(sub_2)

3 Bedroom properties:

myf3(sub_3)

4 Bedroom properties:

myf3(sub_4)

5 Bedroom properties:

myf3(sub_5)

6 Bedroom properties:

myf3(sub_6)

7 Bedroom properties:

myf3(sub_7)

8 Bedroom properties:

myf3(sub_8)

9 Bedroom properties:

myf3(sub_9)