Housing Data Analysis with R

Housing Data Analysis with R

Data Citation:

Anna Montoya and DataCanary. House Prices - Advanced Regression Techniques. https://kaggle.com/competitions/house-prices-advanced-regression-techniques, 2016. Kaggle.

Getting Started:

library(readr) > train <- read_csv("train.csv")
install.packages("dyplr")
library("dyplr")
head(train)
glimpse(train)

Digging into the Means:

summarise(train, mean(SalePrice))
summarise(train, mean(MoSold))
summarise(train, mean(YearBuilt))
summarise(train, mean(LotArea))

Visualizing Drivers Behind Sales Price:

install.packages("ggpubr")
library("ggpubr")
install.packages('ggplot2')
library('ggplot2')
ggplot(train, aes(x=LotArea, y=SalePrice, conf.int = TRUE, cor.coef = TRUE, cor.method = "pearson", xlab = "Lot Area", ylab = "Sales Price")) + ggtitle("Lot Area & Sale Price") + geom_point(color = "steelblue") + coord_cartesian(xlim = c(1, 25000), ylim = c(1, 450000)) + geom_smooth(method = "lm") + scale_y_continuous(labels = dollar) + scale_x_continuous(labels = comma)

ggplot(train, aes(x=YearRemodAdd, y=SalePrice))+ ggtitle("Year Remodeled & Sale Price") + geom_point(color = "purple") + geom_smooth(method="gam",formula = y ~s(x)) + scale_y_continuous(labels = dollar)

Visualizing Mean Sales Price by Neighborhood:

summarise(train, mean(SalePrice))
grouped_data <- train %>% group_by(Neighborhood)
mean_neighborhood_sales_price <- grouped_data %>% summarize(mean_sale_price_by_neighborhood=mean(SalePrice)) 
View(mean_neighborhood_sales_price)
ggplot(mean_neighborhood_sales_price, aes(x=Neighborhood, y=mean_sale_price_by_neighborhood, fill=Neighborhood))+geom_bar(stat = "identity")+ scale_y_continuous(labels = comma) + scale_y_continuous(labels = dollar) + theme(axis.text.x = element_text(angle = 45, hjust = 1))