การดึงข้อมูล sample_price.csv เข้าในโปรแกรม R
df = read.csv("sample_houseprice_2.csv")
head(df)
## Id MSSubClass MSZoning LotFrontage LotArea Street YearBuilt SalePrice
## 1 12 60 RL 85 11924 Pave 2005 345000
## 2 14 20 RL 91 10652 Pave 2006 279500
## 3 21 60 RL 101 14215 Pave 2005 325300
## 4 26 20 RL 110 14230 Pave 2007 256300
## 5 28 20 RL 98 11478 Pave 2007 306000
## 6 33 20 RL 85 11049 Pave 2007 179900
attach(df)
par(mfrow = c(2,2))
plot(LotFrontage,Id,col="khaki",pch=5,main="Dot Graph of LotFrontge with Id",lwd=0.1,type="p")
plot(LotFrontage,SalePrice,col="hotpink",pch=6,main="Dot Graph of LotFrontge with SalePrice",lwd=0.1,type="p")
plot(LotFrontage,LotArea,col="turquoise",pch=2,main="Dot Graph of LotFrontge with LotArea",lwd=0.1,type="p")
plot(LotFrontage,MSSubClass,col="violet",pch=7,main="Dot Graph of LotFrontge with MSSubClass",lwd=0.1,type="p")
par(mfrow = c(1,2))
boxplot(df$LotFrontage,col="#996699",pch=9,main="Vertical LotFrontage graph",lwd=1)
boxplot(df$LotFrontage,col="#669999",horizontal = T,pch=11,main="Horizotal LotFrontage graph",lwd=1)
barplot(table(MSZoning,MSSubClass),col=c("#66FFFF","#FF3399","#CCFF00"),beside=T,legend.text=T,xlab="The BuldingClass" ,main="Example Barplot")
Year = c(2005,2006,2007,2008,2009,2010)
AverageSalePrice = c (mean(SalePrice[YearBuilt == 2005]),
mean(SalePrice[YearBuilt == 2006]),
mean(SalePrice[YearBuilt == 2007]),
mean(SalePrice[YearBuilt == 2008]),
mean(SalePrice[YearBuilt == 2009]),
mean(SalePrice[YearBuilt == 2010]))
plot(Year,AverageSalePrice,col = "#336666",type = "l",main = "Average Seling Price Each Year",cex.lab = 1.5,lwd = 4)