<- c("mouse", "rat", "dog", "cat") list_animals
Assignment 1
Instructions
Please download the following qmd
file and save it in folder called “assignment1”. Complete the questions by adding the code under the relevant chunks.
Please submit your assignment as html file to me via email. Please call your assignment: “yourlastname_assignment1.html”. For example, I would submit something called “popescu_assignment1.html”. Please make sure that it is all in lower case.
To obtain the same look as this template, make sure that your you assignment preamble or YAML looks like below:
---
title: "Assignment 1"
author: "Your Name"
date: "September 13, 2024"
format:
html:
toc: true
number-sections: true
colorlinks: true
smooth-scroll: true
embed-resources: true
---
Note that Headers such as “Question” need to be marked with #
(i.e # Question
will appear as header in bold and larger font after you render the document. It will thus appear in the Table of Contents). Regular text can just be written one line underneath.
1 Question
Remove the word “mouse” from the following vector and create a new object
2 Question
Remove from the following list all the numbers between 30 and 60 (inclusive)
<-c(10, 20, 30, 40, 50, 60, 70) list_no
3 Question
Remove the following elements using the %in% operator from the list: tigers, elephants, giraffes, monkeys
<-c("cheetah", "tigers", "gorillas", "dolphins", "elephants", "giraffes", "monkeys") big_list_animals
4 Question
Explain in your words: Why does the following return “two” > “ten” return TRUE
"two" > "ten"
[1] TRUE
5 Question
Remove the missing data from the following list
<- c("mouse", "rat", NA, "dog", "cat") list_animals
6 Question
Calculate the mean from the following list of numbers
<-c(1, 2, 3, 4, 5, 6, 7, 8, 9, NA, 10, 11, NA) list_no
7 Question
Calculate the median from the following list of numbers
<-c(1, 2, 3, 4, 5, 6, 7, 8, 9, NA, 10, 11, NA) list_no
8 Question
Open the life expectancy dataset
You can download it from:
setwd("/Users/bgpopescu/Dropbox/john_cabot/teaching/stats/assignment1/")
<- read.csv(file = './life-expectancy.csv') life_expectancy
9 Question
Select Italy after 2000 (inclusive)
10 Question
Select US after 2000
11 Question
What is the average life expectancy for Italy after 2000 (inclusive)?
12 Question
What is the average life expectancy for the US after 2000 (inclusive)?
13 Question
What is the median life expectancy for Italy and the US after 2000 (inclusive)?
14 Question
What is the standard deviation life expectancy for Italy and the US after 2000 (inclusive)?
15 Question
What is the highest life expectancy in the entire world?
16 Question
What is the lowest life expectancy in the entire world?
17 Question
What is the name of the country with the highest life expectancy for the entire dataset and all years?
18 Question
What are the years for that country with the highest life expectancy for the entire dataset and all years?
19 Question
What is the name of the country with the lowest life expectancy for the entire dataset and all years?
20 Question
What are the years for that country with the lowest life expectancy for the entire dataset and all years?