Translate

Monday, November 30, 2020

Housing Top 20 cities with R as of 10-2020

 




















download.file("https://s3-us-west-2.amazonaws.com/econresearch/Reports/Core/RDC_InventoryCoreMetrics_State.csv",
              destfile = "State.csv")

download.file("https://s3-us-west-2.amazonaws.com/econresearch/Reports/Core/RDC_InventoryCoreMetrics_Metro.csv",
              destfile = "Metro.csv")

library(ggplot2)
State_data<-read.csv("State.csv")
Metro_data<-read.csv("Metro.csv")
taland

Metro_prices<-Metro_data [which(Metro_data$Hhrank<21),]

Metro_top<-subset(Metro_data,Metro_data$Hrank <21)

Metro_top


ratio_yy<-Metro_prices$price_increased_count_yy/Metro_prices$price_reduced_count_yy


ratio_mm<-Metro_prices$price_increased_count_mm/Metro_prices$price_reduced_count_mm



barplot(ratio_yy, main='Ratio of price increase to decrease in Top 20 cities Y to Y', col="blue",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7, cex.names = 0.6, las=2)

barplot(ratio_mm, main='Ratio of price increase to decrease in Top 20 cities M to M', col="red",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7, cex.names = 0.6, las=2)

        
barplot(Metro_prices$Median.Listing.Price, main='Median Prices for Top 20 cities', col="blue",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        
        
        cex.names = 0.5, las=2)


barplot(Metro_prices$Median.Listing.Price.Y.Y, main='Median Prices for Top 20 cities Y to Y', col="red",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        cex.names = 0.6, las=2)



barplot(Metro_prices$Median.Listing.Price.M.M, main='Median Prices for Top 20 cities M to M', col="blue",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        cex.names = 0.6, las=2)



barplot(Metro_prices$Active.Listing.Count.Y.Y, main='Active Listing for Top 20 cities Y to Y', col="blue",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        cex.names = 0.6, las=2)


barplot(Metro_prices$Active.Listing.Count.M.M, main='Active Listing for Top 20 cities M to M', col="blue",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        cex.names = 0.6, las=2)


barplot(Metro_prices$Days.on.Market.Y.Y, main='Days on Market for Top 20 cities Y to Y', col="red",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        cex.names = 0.6, las=2)



barplot(Metro_prices$price_increased_count_yy, main='Price Increased count for Top 20 cities Y to Y', col="green",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        cex.names = 0.6, las=2)


barplot(Metro_prices$pending_ratio_yy, main='Price Pending ratio for Top 20 cities Y to Y', col="green",
        names.arg=Metro_prices$cbsa_title, cex.axis=0.7,
        cex.names = 0.5, las=2)





ggplot(Metro_prices, aes(x=factor(Hhrank), y=Median.Listing.Price.Y.Y)) +
     geom_col(fill="lightblue", colour="red")
     geom_text(aes(label=Median.Listing.Price.Y.Y), vjust=-0.2)


ggplot(Metro_prices, aes(x=Metro_prices$Median.Listing.Price.Y.Y)) +
  geom_histogram()



barplot(Metro_prices[order(Metro_prices$Median.Listing.Price.Y.Y)], horiz=T)

hist(Metro_prices$Median.Listing.Price)
hist(Metro_data$Median.Listing.Price.Y.Y)

summary(Metro_data$Median.Listing.Price.Y.Y)


barplot(Metro_prices$Median.Listing.Price.Y.Y, cex.names = 0.9, las=2)



# Select Housing Prices for top 20 cities

Housing<- subset(Metro_data, Metro_data$Hhrank <'20') 
Housing<-Housing[order(Housing$Month),]
ratio=Housing$Avg.Listing.Price/Housing$Median.Listing.Price

barplot(Housing$Median.Listing.Price)


d <- density(ratio)
plot(d, main="Average Prices / Median Prices")
polygon(d, col="red", border="blue")




var0<-Housing$Median.Listing.Price
var1<-Housing$Avg.Listing.Price
date <- seq(as.Date("2012-05-01"), by="1 month", length.out=84) 

# Creating Charts

ggplot() + geom_line(aes(x=date,y=var0),color='red') +
  
  geom_line(aes(x=date,y=var1),color='blue') + 
  
  ylab('Housing Prices')+xlab('Date')+
  
  labs(title=" Median Listing Prices (in Red) and Average Listing Prices (in Blue)")




# Percent Chagnes

var2<-Housing$Median.Listing.Price.Y.Y
var3<-Housing$Avg.Listing.Price.Y.Y
date <- seq(as.Date("2012-05-01"), by="1 month", length.out=84) 

ggplot() + geom_line(aes(x=date,y=var2),color='red') +
  
  geom_line(aes(x=date,y=var3),color='blue') + 
  
  ylab('Housing Prices')+xlab('Date')+
  
  labs(title=" Median Listing Prices (in Red) and Average Listing Prices Y to Y (in Blue)")



barplot(Housing$Days.on.Market, main="Days on Market"
        ,
        names.arg = Housing$Month, cex.names = 0.3 )


barplot(Housing$Days.on.Market.Y.Y, main="Days on Market Y to Y"
        ,
        names.arg = Housing$Month, cex.names = 0.3 )


barplot(Housing$Total.Listing.Count.Y.Y, main="Total Listing Y to Y"
        ,
        names.arg = Housing$Month, cex.names = 0.5 )



barplot(Housing$Pending.Listing.Count.Y.Y, main="Pending Listing Y to Y"
        ,
        names.arg = Housing$Month, cex.names = 0.5 )


# Basic line plot with points
ggplot(data=Housing, aes(x=Housing$Month, y=ratio, group=1)) +
  geom_line()+
  geom_point()+
  labs(title=" Ratio ( Average Price / Median Price) ")



# Basic line plot with points
ggplot(data=Housing, aes(x=Housing$Month, y=Housing$Active.Listing.Count.Y.Y, group=1)) +
  geom_line(linetype="dashed")+
  geom_point()+
  labs(title=" Active Listing Count")










U.S. Employment analysis with R as of 10-2020

 















library(Quandl)