Misleading counts
- Dominant language
- R
- Stars
- 399
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
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"))
```

```
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
#>
#> 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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the reproducible R example and inspect how scale_x_upset(sets = c("drama", "comedy", "romance")) calculates and labels intersections. Compare the plotted counts with the nrow() and count(str) results; done means the selected-set counts are consistent with the documented behavior, including when sets is omitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100