-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalyzing-Home-Data.R
108 lines (73 loc) · 2.14 KB
/
Analyzing-Home-Data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Importing Data
```{r}
library(readr)
home_prices <- read_csv("Documents/R Code/home_prices.csv")
str(home_prices)
summary(home_prices)
```
# Calculating Stand Div
``` {r}
sdPrice <- sd(home_prices$PRICE)
sdSQFT <- sd(home_prices$SQFT)
sdYEAR <- sd(home_prices$YEAR)
sdBATHS <- sd(home_prices$BATHS)
sdFEATS <- sd(home_prices$FEATS)
```
# Creating Tables
``` {r}
FEAT_CORNERS <- table(home_prices$FEATS, home_prices$CORNER)
FEAT_CORNERS
FEAT_BATHS <- table(home_prices$FEATS, home_prices$BATHS)
FEAT_BATHS
```
# Creating Data Frames from given data
``` {r}
Temp_DataFr <- data.frame(home_prices$PRICE, home_prices$SQFT, home_prices$BATHS, home_prices$YEAR, home_prices$TAX)
SampleData <- Temp_DataFr[sample(nrow(Temp_DataFr), 30), ]
SampleData
```
# Creating Histograms
``` {r}
hist(SampleData$home_prices.PRICE)
hist(SampleData$home_prices.PRICE, breaks = , main = "Histogram Showing Price Distribution",
xlab = "Prices", col = colors(), ylim=c(0,10))
hist(SampleData$home_prices.TAX)
hist(SampleData$home_prices.TAX, breaks = , main = "Histogram Showing Tax Distribution",
xlab = "Prices", col = colors(), ylim=c(0,10))
```
#Boxplots
``` {r}
par(mfrow=c(2,2))
boxplot(SampleData$home_prices.PRICE,
main = "Boxplot Showing Price Distribution",
xlab = "Prices",
col = "orange",
horizontal = TRUE,
notch = FALSE
)
boxplot(SampleData$home_prices.TAX,
main = "Boxplot Showing Price Distribution",
xlab = "Tax",
col = "blue",
horizontal = TRUE,
notch = FALSE
)
```
# qqplot
```{r}
par(mfrow=c(2,2))
qqnorm(SampleData$home_prices.PRICE, pch = 1, col = "pink", frame = FALSE)
qqline(SampleData$home_prices.PRICE, col = "purple", lwd = 2)
qqnorm(SampleData$home_prices.TAX, pch =1, col = "green", frame = FALSE)
qqline(SampleData$home_prices.TAX, col = "blue", lwd = 2)
```
# Getting boxplot stats
```{r}
boxplot.stats(SampleData$home_prices.PRICE, coef = 1.5, do.conf = TRUE, do.out = TRUE)
boxplot.stats(SampleData$home_prices.TAX, coef = 1.5, do.conf = TRUE, do.out = TRUE)
```
```{r}
x <- SampleData$home_prices.PRICE
y <- SampleData$home_prices.TAX
cor(x, y)
```