เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Visualizing several variables at once with facets

In the visualization you just created, the y-axis extended to fit avg_salary, which was in the thousands. That meant that you couldn't see the bars for the other two variables you were trying to study. Here you'll use faceting so that each variable plot has its own y-axis.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

HR Analytics: Exploring Employee Data in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Reproduce the three side-by-side bar charts from the last exercise, and then add a facet layer using facet_wrap().
  • Within facet_wrap(), facet on measure, and set the scales = parameter to allow the axes to vary by measure.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

library(ggplot2)

# Create three faceted bar charts
___ 
แก้ไขและรันโค้ด