Skip to content

Misleading counts #31

Description

@geotheory

The data doesn't add up as far as I can see:

require(tidyverse)
require(ggupset)

d = tidy_movies |> filter(!duplicated(title)) |> 
  select(title, Genres) |> 
  mutate(Genres = map(Genres, tolower) |> map(unique),
         str = map_chr(Genres, paste, collapse=',')) |>
  filter(str_detect(str, '(drama)|(comedy)|(romance)'))

d |> ggplot(aes(x = Genres)) + geom_bar() + 
  geom_text(stat = 'count', aes(label = ..count..), nudge_y = 50) +
  scale_x_upset(sets = c("drama", "comedy", "romance"))

image

d |> filter(str_detect(str, 'drama'), str_detect(str, 'comedy')) |> nrow()
#> [1] 265
d |> filter(str_detect(str, 'drama'), str_detect(str, 'comedy')) |> count(str)
#> # A tibble: 5 × 2
#>   str                            n
#>   <chr>                      <int>
#> 1 action,comedy,drama            9
#> 2 comedy,drama                 180
#> 3 comedy,drama,romance          68
#> 4 comedy,drama,romance,short     2
#> 5 comedy,drama,short             6

The graphic shows drama + comedy as 195, whereas the actual intersect is 180. It seems you are lumping in the other categories not manually selected for the plot with the sets argument. But if you do this then the app is being inconsistent, because when omitting the sets argument the categories are fully exclusive. In fact the real drama + comedy intersect is 265.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions