MulaiMulai sekarang secara gratis

The geography of happiness

In addition to information regarding their opinions on policy issues, GSS survey respondents also provided the region of the United States in which they live. With this in hand, you can explore the question:

Does this dataset provide evidence of an association between happiness and geography?

Latihan ini adalah bagian dari kursus

Inference for Categorical Data in R

Lihat Kursus

Petunjuk latihan

  • Using gss2016,construct a bar plot of proportions capturing the relationship between region and happy. Plots like this are easier to read when the variable with the fewer number of levels is mapped to fill.
  • Use chisq_stat() to compute the observed chi-squared statistic associated with this bar plot and save it as chi_obs.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Visualize distribution of region and happy
___ +
  # Add bar layer of proportions
  ___
  
# Calculate and save observed statistic
chi_obs <- ___ %>%
  ___

# See the result
chi_obs
Edit dan Jalankan Kode