-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
192 lines (192 loc) · 7.74 KB
/
.Rhistory
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
library(ggplot2)
library(psych)
setwd("C:\\Users\\Osito\\Desktop\\Udacity_R")
redwine <- read.csv("RedWine.csv")
colnames(redwine)[1] <- "Num"
ggplot(aes(x=alcohol,y=quality),data = redwine)+geom_point()
summary(redwine)
ggplot(aes(x=fixed.acidity.,y=quality),data = redwine)+geom_point()
View(redwine)
ggplot(aes(x=fixed.acidity.,y=quality),data = redwine)+geom_point()
names(redwine)
ggplot(aes(x=fixed.acidity.,y=quality),data = redwine)+geom_point()
# Plot the scatterplot for quality and alcohol
ggplot(aes(x=fixed.acidity,y=quality),data = redwine)+geom_point()
ggplot(aes(x=quality,y=alcohol),data = redwine)+geom_point()
ggplot(aes(x=alcohol,y=quality),data = redwine)+geom_point()
ggplot(aes(x=alcohol,y=quality),data = redwine)+geom_line()
ggplot(aes(x=fixed.acidity,y=quality),data = redwine)+geom_point()
ggplot(aes(x=quality,y=alcohol),data = redwine)+geom_point()
View(redwine)
ggplot(data = wine, aes(x = quality, y = fixed.acidity)) +
geom_jitter( alpha = .3) +
geom_boxplot(alpha = .5,color = 'blue') +
stat_summary(fun.y = "mean",
geom = "point",
color = "red",
shape = 8,
size = 4)
ggplot(data = redwine, aes(x = quality, y = fixed.acidity)) +
geom_jitter( alpha = .3) +
geom_boxplot(alpha = .5,color = 'blue') +
stat_summary(fun.y = "mean",
geom = "point",
color = "red",
shape = 8,
size = 4)
ggplot(data = redwine, aes(x=alcohol, fill=quality)) +
geom_density(aes(y=..density..),
binwidth=.5, alpha=.5, position="identity")+
xlab("wine grade") + ylab("alcohol") +
ggtitle("Alchohol Distribuiton of Differnt Wine Grade")
ggplot(aes(x=volatile.acidity),data = redwine)+geom_histogram(binwidth = .2)+
scale_x_continuous(breaks=4:18)
library(ggplot2)
library(psych)
library(grid)
library(gridExtra)
# Plot the quality count
ggplot(aes(x=quality),data=redwine)+geom_bar()
# Plot the pH Count
ggplot(aes(x=pH),data = redwine)+geom_histogram(binwidth = .01)+
scale_x_continuous(breaks = seq(2,4,0.1))
#Plot the Alcohol Count
ggplot(aes(x=alcohol),data = redwine)+geom_histogram()+
scale_x_continuous(breaks = 8:16)
#Plot the residual sugar
ggplot(aes(x=residual.sugar),data = redwine)+geom_histogram()
# Trimming the residual sugar
ggplot(aes(x=residual.sugar),data = redwine)+geom_histogram(binwidth = .1)+
scale_x_continuous(breaks = seq(0,8,0.5))+
coord_cartesian(xlim = c(0,8))
ggplot(aes(x=quality),data=redwine)+geom_bar()+scale_x_discrete(breaks= 0:8)
ggplot(aes(x=quality),data=redwine)+geom_bar()+scale_x_discrete(breaks= seq(0,8,1))
ggplot(aes(x=quality),data=redwine)+geom_bar()+scale_x_discrete()
ggplot(aes(x=quality),data=redwine)+geom_bar()
ggplot(aes(x=volatile.acidity),data = redwine)+geom_histogram(binwidth = .2)+
scale_x_continuous(breaks=4:18)
summary(redwine$fixed.acidity)
summary(redwine)
ggplot(aes(x=volatile.acidity),data = redwine)+geom_histogram(binwidth = .01)+
scale_x_continuous(breaks= 0:2)
ggplot(aes(x=volatile.acidity),data = redwine)+geom_histogram(binwidth = .02)+
scale_x_continuous(breaks= seq(0,2,0.1))
ggplot(aes(x=volatile.acidity),data = redwine)+geom_histogram(binwidth = .02)+
scale_x_continuous(breaks= seq(0,1.7,0.1))
ggplot(aes(x=volatile.acidity),data = redwine)+geom_histogram(binwidth = .01)+
scale_x_continuous(breaks= seq(0,1.7,0.1))
ggplot(aes(x=citric.acidity),data = redwine)+geom_histogram(binwidth = .01)+
scale_x_continuous(breaks= seq(0,1,0.1))
ggplot(aes(x=citric.acid),data = redwine)+geom_histogram(binwidth = .01)+
scale_x_continuous(breaks= seq(0,1,0.1))
ggplot(aes(x=citric.acid),data = redwine)+geom_histogram(binwidth = .01)+
scale_x_continuous(breaks= seq(0,1,0.1))+
coord_cartesian(xlim = c(0,0.8))
ggplot(aes(x=pH),data = redwine)+geom_histogram(binwidth = .05)+
scale_x_continuous(breaks= seq(2,4.5,0.1))
ggplot(aes(x=pH),data = redwine)+geom_histogram(binwidth = .02)+
scale_x_continuous(breaks= seq(2,4.5,0.1))
summary(redwine$citric.acid)
ggplot(aes(x=pH),data = redwine)+geom_histogram(binwidth = .01)+
scale_x_continuous(breaks= seq(2,4.5,0.1))
#Plot the quality for higher alcohol
ggplot(aes(x=quality),data = subset(redwine,redwine$alcohol>10.42))+
geom_bar()+ggtitle("Quality with Higher Alcohol")
#plot the quality for lower alcohol
ggplot(aes(x=quality),data = subset(redwine,redwine$alcohol<=10.42))+
geom_bar()+ggtitle("Quality with Lower Alcohol")
#Plot the quality for higher volatile acidity
ggplot(aes(x=quality),data = subset(redwine,redwine$volatile.acidity>0.53))+
geom_bar()+ggtitle("Quality with Higher volatile.acidity")
#plot the quality for lower volatile acidity
ggplot(aes(x=quality),data = subset(redwine,redwine$volatile.acidity<=0.53))+
geom_bar()+ggtitle("Quality with Lower volatile.acidity")
summary(redwine$volatile.acidity)
ggplot(data = redwine,
aes(y = pH, x = alcohol,
color = rating)) +
geom_point(alpha = 0.8, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
scale_color_brewer(palette = "Blues",
guide=guide_legend(title='Rating'))
```{r echo=FALSE,warning=FALSE,message=FALSE, Univariate_Plots}
str(redwine)
summary(redwine)
#Creating new variables
#Transforming Quality from an Integer to a Factor
redwine$quality <- factor(redwine$quality, ordered = T)
#Creating a new Factored Variable called 'Rating'
redwine$rating <- ifelse(redwine$quality < 5, 'bad', ifelse(
redwine$quality < 7, 'acceptable', 'excellent'))
redwine$rating <- ordered(redwine$rating,
levels = c('bad', 'acceptable', 'excellent'))
View(redwine)
ggplot(data = redwine,
aes(y = pH, x = alcohol,
color = rating)) +
geom_point(alpha = 0.8, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
scale_color_brewer(palette = "Blues",
guide=guide_legend(title='Rating'))
ggplot(data = redwine,
aes(y = pH, x = alcohol,
color = rating)) +
geom_point(alpha = 0.8, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
scale_color_brewer(palette = "Reds",
guide=guide_legend(title='Rating'))
ggplot(data = redwine,
aes(y = citric.acid, x = volatile.acidity,
color = quality)) +
geom_point(alpha = 0.8, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
facet_wrap(~rating) +
scale_color_brewer(palette='Oranges',
guide=guide_legend(title='Quality'))
ggplot(data = redwine,
aes(y = citric.acid, x = volatile.acidity,
color = quality)) +
geom_point(alpha = 0.8, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
facet_wrap(~rating) +
scale_color_brewer(palette='Yellows',
guide=guide_legend(title='Quality'))
ggplot(data = redwine,
aes(y = citric.acid, x = volatile.acidity,
color = quality)) +
geom_point(alpha = 0.5, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
facet_wrap(~rating) +
scale_color_brewer(palette='Reds',
guide=guide_legend(title='Quality'))+
xlab(" volatile acidity (g/dm^3)")+ylab("Citric Acid (g/dm^3)")+
ggtitle("Correlation between Citric Acid and Volatile Acid in Different Ratings and Quality")
ggplot(data = redwine,
aes(y = citric.acid, x = volatile.acidity,
color = quality)) +
geom_point(alpha = 0.5, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
facet_wrap(~rating) +
scale_color_brewer(palette='Spectral',
guide=guide_legend(title='Quality'))+
xlab(" volatile acidity (g/dm^3)")+ylab("Citric Acid (g/dm^3)")+
ggtitle("Correlation between Citric Acid and Volatile Acid in Different Ratings and Quality")
#Plot the acid relationships
ggplot(data = redwine,
aes(y = citric.acid, x = volatile.acidity,
color = quality)) +
geom_point(alpha = 0.5, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
facet_wrap(~rating) +
scale_color_brewer(palette='Blues',
guide=guide_legend(title='Quality'))+
xlab(" volatile acidity (g/dm^3)")+ylab("Citric Acid (g/dm^3)")+
ggtitle("Correlation between Citric Acid and Volatile Acid in Different Ratings and Quality")
ggplot(data = redwine,
aes(y = citric.acid, x = volatile.acidity,
color = quality)) +
geom_point(alpha = 0.8, size = 1) +
geom_smooth(method = "lm", se = FALSE,size=1) +
facet_wrap(~rating) +
scale_color_brewer(palette='Greens',
guide=guide_legend(title='Quality'))