Exercise: indexing

Choose your favorite book, movie, or game as a theme. Based on this theme, create three vectors (vec1, vec2, and vec3) of different data types (e.g., numeric, character, logical). Each vector should contain at least 5 elements.

Try to create a dataframe, matrix and list from some of your vectors.

Exercise

1) select the 4th element from one of your vectors.
2) combine two of your vectors to “vec4”. Does the class change?
3) select your favourite element (e.g. character) from both your data frame and your matrix. For the data frame, presen. Sort the dataset by emissions. In which year, in which country and from which source did the largest annual CO2 emissions per capita originate?
6) Which countries produced the 10 greatest oil emissions in 2020?
7) How many countries produced fewer gas emissions in 2020 than the average (mean)?

Updated: