Sandbox Tasks

Solve the following tasks using R. Each of the tasks are meant to be simple and can be solved combining the code we have seen in the first session.

  1. Load the example dataset mtcars which ships with R. Use data() to do so. Get an idea of the meaning of the variables in this dataset by reading the description.

  2. Which is the most economical car? Hint: Maximum miles per gallon (mpg)

  3. Display the first 3 rows of the mtcars data.frame

  4. Which is the most economical car with 8 cylinders? Hint: create a subset first and then proceed as in 2.

  5. How many cars with automatic gear are in the dataset? Hint: column am holds the information. Explore functions: table(), sum().

  6. Create vector called a which contains 10 elements from 0 to 9

  7. Create a vector b that contains all elements of a except the 7th element. Which is number is missing compared to vector a?