Please download the answer file and edit it on RStudio. Write your student number in the correct place at the beginning of the answer file. When you finish, send the answers.R
file to the answers’ mailbox. All questions are independent and can be answered in any order.
rubber.txt
, store it in your computer, and read it into a data frame called rubber
. Show summary(rubber)
.## id rep N x1 x2
## Min. :1.000 a:54 Min. :1.000 Min. : 10.0 Min. : 15.7
## 1st Qu.:2.000 b:55 1st Qu.:1.000 1st Qu.: 70.0 1st Qu.:194.0
## Median :3.000 c:51 Median :2.000 Median :200.0 Median :290.0
## Mean :2.994 d: 9 Mean :1.529 Mean :189.3 Mean :283.5
## 3rd Qu.:4.000 s: 1 3rd Qu.:2.000 3rd Qu.:250.0 3rd Qu.:377.5
## Max. :7.000 Max. :2.000 Max. :434.0 Max. :502.0
##
## y1 y2 src
## Min. : 12.9 Min. : 11.3 185a34:40
## 1st Qu.:207.0 1st Qu.:280.0 1e4a6e:14
## Median :309.5 Median :400.0 3b2b4b:15
## Mean :315.2 Mean :402.4 6ed952:30
## 3rd Qu.:409.5 3rd Qu.:515.0 7183bd:30
## Max. :775.0 Max. :775.0 andres:30
## e3459b:11
# write here
rubber$src
and the number of times each one appears. Show this table in a nice way, using the kable
command. There may be some warnings, but they are not important.Var1 | Freq |
---|---|
185a34 | 40 |
1e4a6e | 14 |
3b2b4b | 15 |
6ed952 | 30 |
7183bd | 30 |
andres | 30 |
e3459b | 11 |
# write here
rubber
. Create a new column called dx
with the values x2-x1
. Create a new column called dy
, with the values y2-y1
. Create a new column called clip
, with the values y1-x2
. Show summary(rubber)
# write here
## id rep N x1 x2
## Min. :1.000 a:54 Min. :1.000 Min. : 10.0 Min. : 15.7
## 1st Qu.:2.000 b:55 1st Qu.:1.000 1st Qu.: 70.0 1st Qu.:194.0
## Median :3.000 c:51 Median :2.000 Median :200.0 Median :290.0
## Mean :2.994 d: 9 Mean :1.529 Mean :189.3 Mean :283.5
## 3rd Qu.:4.000 s: 1 3rd Qu.:2.000 3rd Qu.:250.0 3rd Qu.:377.5
## Max. :7.000 Max. :2.000 Max. :434.0 Max. :502.0
##
## y1 y2 src dx dy
## Min. : 12.9 Min. : 11.3 185a34:40 Min. :-47.90 Min. :-105.00
## 1st Qu.:207.0 1st Qu.:280.0 1e4a6e:14 1st Qu.: 85.00 1st Qu.: 80.00
## Median :309.5 Median :400.0 3b2b4b:15 Median :106.00 Median : 95.00
## Mean :315.2 Mean :402.4 6ed952:30 Mean : 94.18 Mean : 87.21
## 3rd Qu.:409.5 3rd Qu.:515.0 7183bd:30 3rd Qu.:130.25 3rd Qu.: 120.75
## Max. :775.0 Max. :775.0 andres:30 Max. :233.00 Max. : 200.00
## e3459b:11
## clip
## Min. :-70.00
## 1st Qu.: 17.00
## Median : 19.00
## Mean : 31.75
## 3rd Qu.: 20.00
## Max. :435.00
##
# write here
clean_rubber
containing a subset of rubber
, where clip>0
and clip<50
. Plot the histogram of clean_rubber$clip
# write here
src=="andres"
when N==1
and when N==2
. Color should correspond to id
# write here
src=="185a34"
and N==2
. Build a linear model for these points and store it on the variable model
. Draw the line described by the model.# write here
# write here
## (Intercept) dx
## 45.6654794 0.4011217
# write here