Assignment 2. R preliminaries

Due by 5:00 PM on Wednesday, November 2, 2022

To do yourself

To submit on Canvas

  1. Describe different ways to install R packages. Test each method by installing packages of your choice (e.g., Hmisc, lme4, MASS, dslabs). Install a GitHub package (e.g., jokergoo/ComplexHeatmap). How much time each method/package took? Hint: use system.time function. Copy-paste selected output and describe your observations.

  2. Describe all ways how to find path(s) where R packages are installed. Copy-paste selected output and describe your observations. Hint: you did it in the first homework.

  3. What is unusual about each of the following objects?

num_char     <- c(1, 2, 3, "a")
num_logical  <- c(1, 2, 3, TRUE)
char_logical <- c("a", "b", "c", TRUE)
tricky       <- c(1, 2, 3, "4")
  1. Create two numeric objects, two character objects, two logical objects. Demonstrate up to three R functions operating on each pair of objects (e.g., correlation between two numeric objects). Copy-paste selected output and describe your observations.

  2. Download alcohol consumption data per country from https://github.com/fivethirtyeight/data/tree/master/alcohol-consumption and demonstrate the use of basic summary functions (min, max, mean, etc.). Ask questions like which country(es) consumes most/least liters of pure alcohol, what’s the average number of beer servings, which country prefer only one type of alcohol (and what type). Describe your observation.

Alternatively, use any built-in R datasets or a dataset from TidyTuesday

  • Submit your homework as a text or Word document. Files should be named, e.g., LASTNAME-FIRSTNAME-HW02.