Gráficos de Contagem

Outra ótima maneira de representar duas variáveis pseudométricas é com o gráfico de contagem. Aqui, as combinações mais frequentes são exibidas em maior tamanho. Para isso, chamamos a função geom_count():

countplot <- ggplot( 
  pss, 
  aes(
    trstplt, 
    trstlgl
  )
) + 
  geom_count()

countplot
## Warning: Removed 23 rows containing non-finite outside the scale range
## (`stat_sum()`).

Coloração

Também podemos adicionar cores aqui:

ggplot(
  pss, 
  aes(
    trstplt, 
    trstlgl)) + 
  geom_count(
    aes(
      color = ..n.., 
      size = ..n..
    )
  ) +  
  guides(color = "legend")  
## Warning: The dot-dot notation (`..n..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(n)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 23 rows containing non-finite outside the scale range
## (`stat_sum()`).

Por fim, você aprenderá como representar uma distribuição bivariada também!