Untitled
Question 1
library
(plyr)
t1 <-
read.csv
(
"slots.csv"
,
stringsAsFactors =
TRUE
)
t2 <-
read.table
(
"slots.txt"
,
stringsAsFactors =
TRUE
,
col.names =
colnames
(t1))
t2
$
w1 <-
revalue
(
as.factor
(t2
$
w1),
c
(
"1"
=
"B"
,
"2"
=
"BB"
,
"3"
=
"BBB"
,
"5"
=
"DD"
,
"6"
=
"C"
))
t2
$
w2 <-
revalue
(
as.factor
(t2
$
w2),
c
(
"1"
=
"B"
,
"2"
=
"BB"
,
"3"
=
"BBB"
,
"5"
=
"DD"
,
"6"
=
"C"
))
t2
$
w3 <-
revalue
(
as.factor
(t2
$
w3),
c
(
"1"
=
"B"
,
"2"
=
"BB"
,
"3"
=
"BBB"
,
"5"
=
"DD"
,
"6"
=
"C"
))
Question 2
#install.packages("remotes")
library
(
"remotes"
)
install_bitbucket
(
perossichi/DataAnalytics
)
## Skipping install of
DataAnalytics
from a bitbucket remote, the SHA1 (a2ca2153) has not changed sinc
##
Use
force = TRUE
to force installation
data
(beerprod,
package =
"DataAnalytics"
)
par
(
mfrow=
c
(
1
,
2
))
hist
(beerprod
$
b_prod,
col=
"blue"
,
main =
"Monthly Beer Production"
)
rug
(beerprod
$
b_prod,
ticksize =
0.03
,
side =
1
,
lwd =
0.5
)
boxplot
(beerprod
$
b_prod,
col=
"green3"
,
main =
"Beer Production Boxplot"
)
rug
(beerprod
$
b_prod,
ticksize =
0.03
,
side =
2
,
lwd =
0.5
)
1

Monthly Beer Production
beerprod$b_prod
Frequency
12
14
16
18
20
0
5
10
15
13
14
15
16
17
18
19
Beer Production Boxplot
Question 3
#install.packages("ggplot2")
library
(ggplot2)
data
(diamonds)
# a)-1
ggplot
(diamonds,
aes
(
x=
diamonds
$
price,
y=
log
(diamonds
$
price)))
+
geom_line
(
color=
"blue"
)
+
labs
(
x=
"Diamond Price"
,
y=
"log() Price"
,
title =
"Log Price vs Diamond Price"
)
+
theme_classic
()
2

6
7
8
9
10
0
5000
10000
15000
Diamond Price
log() Price
Log Price vs Diamond Price
# a)-2
par
(
mfrow=
c
(
1
,
2
))
hist
(diamonds
$
price,
col=
"blue"
,
main=
"Diamonds Price"
)
plot
(
log
(diamonds
$
price)
~
diamonds
$
price,
col=
"grey"
,
main =
"Log Diamond Price"
)
3

Diamonds Price
diamonds$price
Frequency
0
5000
15000
0
5000
10000
15000
0
5000
15000
6
7
8
9
10
Log Diamond Price
diamonds$price
log(diamonds$price)
# a)-3
sqrt <- (diamonds
$
price)
^
(
1
/
2
)
sq <- (diamonds
$
price)
^
(
2
)
par
(
mfrow=
c
(
1
,
2
))
plot
(diamonds
$
price
~
sqrt,
col=
"grey"
,
main=

