-
Notifications
You must be signed in to change notification settings - Fork 2
/
07-Exploring-Data.Rmd
126 lines (102 loc) · 2.54 KB
/
07-Exploring-Data.Rmd
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
Başlık : "Verideki Bilgileri Keşfetme"
Anlatan : "Tirendaz Akademi"
---
#Veri Setini Tanıma
```{r}
veri<-readRDS("custdata.RDS")
str(veri)
```
#Tek Değişken için Grafikler
## Histogram Grafikleri
```{r}
library(ggplot2)
ggplot(veri, aes(x=gas_usage))+
geom_histogram(binwidth = 10, fill="red")
```
## Yoğunluk Grafikleri
```{r}
library(scales)
ggplot(veri, aes(x=income))+
geom_density()+
scale_x_continuous(labels=dollar)
```
```{r}
ggplot(veri, aes(x=income))+geom_density()+
scale_x_log10(breaks=c(10,100,1000,10000,10000,1000000),labels=dollar)
```
##Bar Grafikleri
```{r}
ggplot(veri, aes(x=marital_status))+geom_bar(fill="red")
```
```{r}
ggplot(veri, aes(x=state_of_res))+geom_bar(fill="red")+coord_flip()
```
##Nokta Grafikleri
```{r}
library(WVPlots)
ClevelandDotPlot(veri, "state_of_res",sort=1, title="İkamet", color = "red")+
coord_flip()
```
##Çizgi Grafikleri
```{r}
x<-runif(100)
y<-x^2+0.2*x
ggplot(data.frame(x=x,y=y),aes(x=x,y=y))+geom_line()
```
# İki Değişken için Grafikler
```{r}
veri2<-subset(veri, 0<age & age<100 & 0 < income & income <200000)
cor(veri2$age, veri2$income)
```
## Nokta Grafikleri
```{r}
set.seed(1234)
data<-dplyr::sample_frac(veri2, size=0.1, replace=FALSE)
ggplot(data, aes(x=age,y=income))+geom_point()+
geom_smooth()+
ggtitle("Yaş ile Gelir İlişkisi")
```
## Hexbin Grafikleri
```{r}
library(hexbin)
HexBinPlot(veri2, "age","income", "Gelir & Yaş")+geom_smooth(color="black",se=FALSE)
```
## Bar Grafikleri
```{r}
ggplot(veri, aes(x=marital_status, fill=health_ins))+
geom_bar(position = "dodge")
```
```{r}
ShadowPlot(veri, "marital_status", "health_ins", title="Medeni Durum & S. Sigorta")
```
```{r}
ggplot(veri, aes(x=marital_status, fill=health_ins))+
geom_bar(position = "fill")
```
```{r}
veri3<-subset(veri, !is.na(housing_type))
ggplot(veri3, aes(x=housing_type, fill=marital_status))+geom_bar(position = "dodge")+
scale_fill_brewer(palette = "Set1")+
coord_flip()
```
```{r}
ggplot(veri3, aes(x=marital_status))+geom_bar(fill="red")+
facet_wrap(veri3$housing_type, scale="free_x")+
coord_flip()
```
# İki Sürekli Değişken için Grafikler
## Çizgi Grafikleri
```{r}
veri4<-subset(veri2, marital_status %in% c("Never married", "Widowed"))
ggplot(veri4, aes(x=age, color=marital_status, linetype=marital_status))+
geom_density()+
scale_color_brewer(palette = "Dark2")
```
## Histogram Grafikleri
```{r}
ShadowHist(veri4,"age","marital_status", "Evlenmeyen & Dul", binwidth = 5)
```
```{r}
ggplot(veri2, aes(x=age))+geom_density()+facet_wrap(~marital_status)
```