Assignment 3
PS 3780 Data Literacy & Visualization, Summer 2022
Due Date: Thursday, June 9, 2022 at 11:59 p.m.
Please save your answer to these questions as one .pdf �le (use the �save as�
function in most word processors). Be sure to include your name, your teammate's name
if there is anyone, and the assignment number. Submit the �le to Carmen by the due
date.
Basics of R
CIA World Factbook
Use the CIA World Factbook country comparison guide to download a numeric .csv
dataset https:
www.cia.gov/the-world-factbook
eferences/guide-to-country-comparisons/.
Import the dataset into R. Please answer the following questions with R and copy the
commands that you use for answering each question.
1. (.5 pt) Which dataset did you download and what is the stored name of the dataset
in R?
2. (.5 pt) What is the average value of your chosen variable? What is the median
value of your chosen variable?
3. (.5 pt) Does that average value happen to be the actual value of any country?
4. (.5 pt) Does that median value happen to be the actual value of any country?
5. (.5 pt) Which country has the lowest value?
6. (.5 pt) Which country is ranked 10th, 30th, and 50th respectively?
7. (.5 pt) Which country ranks higher in the variable that you choose, Namibia o
Botswana (the data might be missing in your dataset, but at least you need to
write down the R command that you use for inquiry)?
1
https:
www.cia.gov/the-world-factbook
eferences/guide-to-country-comparisons
Presidential Approval
Visit 538 to �nd data on the popularity of Joe Biden through the �rst term of his pres-
ident. At the bottom of their interactive, https:
projects.fivethirtyeight.com
iden-approval-rating/, there is a link to download the associated polls. Import the
dataset into R. Please answer the following questions with R and copy the commands
that you use for answering each question.
1. (.5 pt) Is the dataset properly read in? How many observations and variables are
in the dataset?
2. (.5 pt) List the di�erent values of �population�.
3. (1 pt) What is the average approval for polls of each �population�? Does there
appear to be much of a di�erence? (Hint: Create and save a subset of the data fo
each methodology using indexing, subsetting, or �ltering and �nd the mean of that
new dataset.)
Presidential Approval Advanced
Use the same 538 dataset to address the following questions. Again, copy the com-
mands that you use. When asked for the co
elation between two variables, use the
function cor( x , y ) for the speci�c x and y that you want to compare. Make sure to use
the form `dataset$variable' to indicate a variable that exists within a dataset.
1. (.5 pt) Using approve and disapprove, create two new variables in the dataset: a
variable named net measuring the di�erence of approve and disapprove (subtract
the variables) and a variable named ratio measuring the ratio of approve to dis-
approve (divide the variables). What is the average of net and ratio?
2. (1 pt) What is the value of net and ratio (the two variables you just created) fo
the polls that had the largest and smallest sample size?
3. (1 pt) What is the co
elation between the pairs net and sample size and ratio and
sample size? How do these co
elations relate to the values found in the previous
question?
2
https:
projects.fivethirtyeight.com
iden-approval-rating
https:
projects.fivethirtyeight.com
iden-approval-rating
Assignment 3
PS 3780 Data Literacy & Visualization, Summer 2022
Due Date: Thursday, June 9, 2022 at 11:59 p.m.
Please save your answer to these questions as one .pdf �le (use the �save as�
function in most word processors). Be sure to include your name, your teammate's name
if there is anyone, and the assignment number. Submit the �le to Carmen by the due
date.
Basics of R
CIA World Factbook
Use the CIA World Factbook country comparison guide to download a numeric .csv
dataset https:
www.cia.gov/the-world-factbook
eferences/guide-to-country-comparisons/.
Import the dataset into R. Please answer the following questions with R and copy the
commands that you use for answering each question.
1. (.5 pt) Which dataset did you download and what is the stored name of the dataset
in R?
2. (.5 pt) What is the average value of your chosen variable? What is the median
value of your chosen variable?
3. (.5 pt) Does that average value happen to be the actual value of any country?
4. (.5 pt) Does that median value happen to be the actual value of any country?
5. (.5 pt) Which country has the lowest value?
6. (.5 pt) Which country is ranked 10th, 30th, and 50th respectively?
7. (.5 pt) Which country ranks higher in the variable that you choose, Namibia o
Botswana (the data might be missing in your dataset, but at least you need to
write down the R command that you use for inquiry)?
1
https:
www.cia.gov/the-world-factbook
eferences/guide-to-country-comparisons
Presidential Approval
Visit 538 to �nd data on the popularity of Joe Biden through the �rst term of his pres-
ident. At the bottom of their interactive, https:
projects.fivethirtyeight.com
iden-approval-rating/, there is a link to download the associated polls. Import the
dataset into R. Please answer the following questions with R and copy the commands
that you use for answering each question.
1. (.5 pt) Is the dataset properly read in? How many observations and variables are
in the dataset?
2. (.5 pt) List the di�erent values of �population�.
3. (1 pt) What is the average approval for polls of each �population�? Does there
appear to be much of a di�erence? (Hint: Create and save a subset of the data fo
each methodology using indexing, subsetting, or �ltering and �nd the mean of that
new dataset.)
Presidential Approval Advanced
Use the same 538 dataset to address the following questions. Again, copy the com-
mands that you use. When asked for the co
elation between two variables, use the
function cor( x , y ) for the speci�c x and y that you want to compare. Make sure to use
the form `dataset$variable' to indicate a variable that exists within a dataset.
1. (.5 pt) Using approve and disapprove, create two new variables in the dataset: a
variable named net measuring the di�erence of approve and disapprove (subtract
the variables) and a variable named ratio measuring the ratio of approve to dis-
approve (divide the variables). What is the average of net and ratio?
2. (1 pt) What is the value of net and ratio (the two variables you just created) fo
the polls that had the largest and smallest sample size?
3. (1 pt) What is the co
elation between the pairs net and sample size and ratio and
sample size? How do these co
elations relate to the values found in the previous
question?
2
https:
projects.fivethirtyeight.com
iden-approval-rating
https:
projects.fivethirtyeight.com
iden-approval-rating