Assignment 1

Author

Your Name

Published

September 13, 2023

Instructions

Please submit your assignment as html file to me via email. Please call your assignment: “yourname_assignment1.html”. For example, I would submit submit something called “popescu_assignment1.html”. Please make sure that it is all in lower case. Please answer all the questions below

1 Question

Remove the word “mouse” from the following vector and create a new object

list_animals <- c("mouse", "rat", "dog", "cat")

2 Question

Remove from the following list all the numbers between 30 and 60 (inclusive)

list_no<-c(10, 20, 30, 40, 50, 60, 70)

3 Question

Remove the following elements using the %in% operator from the list: tigers, elephants, giraffes, monkeys

big_list_animals<-c("cheetah", "tigers", "gorillas", "dolphins", "elephants", "giraffes", "monkeys")

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

list_animals <- c("mouse", "rat", NA, "dog", "cat")

6 Question

Calculate the mean from the following list of numbers

list_no<-c(1, 2, 3, 4, 5, 6, 7, 8, 9, NA, 10, 11, NA)

7 Question

Calculate the median from the following list of numbers

list_no<-c(1, 2, 3, 4, 5, 6, 7, 8, 9, NA, 10, 11, NA)

8 Question

Open the life expectancy dataset

You can download it from:

setwd("/Users/bgpopescu/Dropbox/john_cabot/teaching/stats/assignment1/")
life_expectancy <- read.csv(file = './life-expectancy.csv')

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?