(1.) Please begin from Question (1.).
Do not skip.
(2.) Two types of solutions will be given for Question (1.)
The rest of the questions will be done using one type of solution.
(3.) These steps and solutions are for Statistics students.
There are more detailed steps and solutions that I could use for Data Science and Computer Science students.
Scatter Diagrams
Question 1
Question 2
Question 3
R/RStudio
Arguments for the Plot Function
Plot Characters
Data Presentation
Descriptive Statistics
Probability Distributions
Inferential Statistics
(1.) The table provided below shows paired data for the heights of a certain country's presidents and their main opponents
in the election campaign.
(a.) Construct a scatterplot.
(b.) Does there appear to be a correlation between the president's height and his opponent's height?
A. Yes, there appears to be a correlation. As the president's height increases, his opponent's height decreases.
B. Yes, there appears to be a correlation. As the president's height increases, his opponent's height increases.
C. Yes, there appears to be a correlation. The candidate with the highest height usually wins.
D. No, there does not appear to be a correlation because there is no general pattern to the data.
PresidentHeightVersusOpponentHeight
XaxisVersusYaxis
PresidentHeightVersusOpponentHeight
dataset.
plot
function with only one argument plot
PresidentHeightVersusOpponentHeight
plot(PresidentHeightVersusOpponentHeight)(a.)
xlim = c(160, 200) ylim = c(160, 200)where:
xlim
is the limit for the x-axis. This includes the minimum value and the maximum value for the x-axis ylim
is the limit for the y-axis. This includes the minimum value and the maximum value for the y-axis c
is the function that selects and combines the values into a list. It is used when we need to pass a list (in this case: the values in both axis) as a parameter. pch = 16where:
pch
is the Plot Character pch
= 16 is the value of the plot character for filled circle xlab = "President's height" ylab = "Opponent's height"(6.) 2nd Solution: Let us use more arguments (the ones we just listed) with the
plot
function
plot(PresidentHeightVersusOpponentHeight, xlab = "President's height", ylab = "Opponent's height", xlim = c(160, 200), ylim = c(160, 200), pch = 16)
(2.) The table lists weights (pounds) and highway mileage amounts (mpg) for seven automobiles.
Weight (lb) | 3185 | 3420 | 3835 | 4465 | 4650 | 2140 | 3745 |
Highway (mpg) | 32 | 30 | 26 | 22 | 21 | 39 | 28 |
plot(WeightVersusHighway, xlab = "Weight (lb)", ylab = "Highway (mpg)", xlim = c(2000, 5000), ylim = c(20, 40), pch = 16)
(3.) This data is from a study comparing the amount of tar and carbon monoxide (CO) in cigarettes.
Use tar for the horizontal scale and use carbon monoxide (CO) for the vertical scale.
(a.) Construct a scatterplot.
(b.) Is there a relationship between cigarette tar and CO?
A. Yes, as the amount of tar increases the amount of carbon monoxide decreases.
B. Yes, as the amount of tar increases the amount of carbon monoxide also increases.
C. No, there appears to be no relationship.
plot(TarVersusCO, xlab = "Tar", ylab = "CO", xlim = c(0, 20), ylim = c(0, 20), pch = 15)
Plot Character is the argument that sets the characters/points in a plot.
It is denoted by pch
It has numeric values that shows several symbols used to represent the points in a plot.
Value | Symbol | Argument |
---|---|---|
0 | Square | pch = 0 |
1 | Circle | pch = 1 |
2 | Triangle: Vertex up | pch = 2 |
3 | Plus | pch = 3 |
4 | Cross | pch = 4 |
5 | Diamond | pch = 5 |
6 | Triangle: Vertex down | pch = 6 |
7 | Cross inside Square (Square Cross) | pch = 7 |
8 | Asterisk | pch = 8 |
9 | Plus inside Diamond (Diamond Plus) | pch = 9 |
10 | Plus inside Circle (Circle Plus) | pch = 10 |
11 | Two Triangles: Vertex up and down | pch = 11 |
12 | Plus inside Square (Square Plus) | pch = 12 |
13 | Cross inside Circle (Circle Cross) | pch = 13 |
14 | Triangle: Vertex up inside Square | pch = 14 |
15 | Filled/Shaded Square | pch = 15 |
16 | Filled/Shaded Circle | pch = 16 |
17 | Filled/Shaded Triangle: Vertex up | pch = 17 |
18 | Filled/Shaded Diamond | pch = 18 |
19 | Filled/Shaded Circle | pch = 19 |
20 | Small Shaded Circle | pch = 20 |
21 | Circle | pch = 21 |
22 | Square | pch = 22 |
23 | Diamond | pch = 23 |
24 | Triangle: Vertex up | pch = 24 |
25 | Triangle: Vertex down | pch = 25 |