MulaiMulai sekarang secara gratis

Arranging observations by life expectancy

You use arrange() to sort observations in ascending or descending order of a particular variable. In this case, you'll sort the dataset based on the lifeExp variable.

Latihan ini adalah bagian dari kursus

Introduction to the Tidyverse

Lihat Kursus

Petunjuk latihan

  • Sort the gapminder dataset in ascending order of life expectancy (lifeExp).
  • Sort the gapminder dataset in descending order of life expectancy.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

library(gapminder)
library(dplyr)

# Sort in ascending order of lifeExp


  
# Sort in descending order of lifeExp

Edit dan Jalankan Kode