BaşlayınÜcretsiz Başlayın

Visualizing numeric vs. categorical

If the explanatory variable is categorical, the scatter plot that you used before to visualize the data doesn't make sense. Instead, a good option is to draw a histogram for each category.

The Taiwan real estate dataset has a categorical variable in the form of the age of each house. The ages have been split into 3 groups: 0 to 15 years, 15 to 30 years, and 30 to 45 years.

taiwan_real_estate is available and ggplot2 is loaded.

Bu egzersiz

Introduction to Regression in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Using taiwan_real_estate, plot a histogram of price_twd_msq with 10 bins.
  • Facet the plot by house_age_years to give 3 panels.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Using taiwan_real_estate, plot price_twd_msq
___ +
  # Make it a histogram with 10 bins
  ___ +
  # Facet the plot so each house age group gets its own panel
  ___
Kodu Düzenle ve Çalıştır