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

Calculating means by category

A good way to explore categorical variables is to calculate summary statistics such as the mean for each category. Here, you'll look at grouped means for the house prices in the Taiwan real estate dataset.

taiwan_real_estate is available and dplyr is loaded.

Bu egzersiz

Introduction to Regression in R

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

Egzersiz talimatları

  • Group taiwan_real_estate by house_age_years.
  • Summarize to calculate the mean price_twd_msq for each group, naming the column mean_by_group.
  • Assign the result to summary_stats and look at the numbers.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

summary_stats <- taiwan_real_estate %>% 
  # Group by house age
  ___ %>% 
  # Summarize to calculate the mean house price/area
  ___(mean_by_group = ___)

# See the result
summary_stats
Kodu Düzenle ve Çalıştır