MulaiMulai sekarang secara gratis

Position in bar and col plots

Let's see how the position argument changes geom_bar().

We have three position options:

  • stack: The default
  • dodge: Preferred
  • fill: To show proportions

While we will be using geom_bar() here, note that the function geom_col() is just geom_bar() where both the position and stat arguments are set to "identity". It is used when we want the heights of the bars to represent the exact values in the data.

In this exercise, you'll draw the total count of cars having a given number of cylinders (fcyl), according to manual or automatic transmission type (fam).

Latihan ini adalah bagian dari kursus

Introduction to Data Visualization with ggplot2

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Plot fcyl, filled by fam
___ +
  # Add a bar layer
  ___
Edit dan Jalankan Kode