dreamRs / esquisse

RStudio add-in to make plots interactively with ggplot2
https://dreamrs.github.io/esquisse
Other
1.76k stars 227 forks source link

One categorical variable is missing from the Data tab #218

Closed jmouchnino closed 2 months ago

jmouchnino commented 1 year ago

I use this data

library(dplyr)
tuesdata <- tidytuesdayR::tt_load(2022, week = 29)
technology <- tuesdata$technology %>% select(variable, iso3c, year, value) %>% dplyr::slice_sample(n = 30000)

esquisse::esquisser()

image Capture d’écran 2022-07-24 210617

Why are the categorical variables missing from the Data tab ? I'm sure that once it was possible to filter the categorical variables in the app.

pvictor commented 1 year ago

Variables that contain only unique values are automatically discarded. The idea behind this is that it is not interesting to visually represent a single line of a data.frame. Does this bother your usage?

jmouchnino commented 1 year ago

The iso3c variable doesn't contain unique values only

set.seed(7)
tuesdata <- tidytuesdayR::tt_load(2022, week = 29)
technology <- tuesdata$technology %>% select(variable, iso3c, year, value) %>% dplyr::slice_sample(n = 30000)

technology$iso3c %>% table() %>% head
# ABW AFG AGO ALB AND ANT 
#  35  96 129 155  22   3 

esquisse::esquisser(technology)
pvictor commented 1 year ago

Ah yes, sorry. If there are more than 50 unique value, the filter isn't generated. Maybe we should reconsider that rule.

emilopezcano commented 10 months ago

I would suggest adding an argument to the esquise_server() function and modify the call to filter_data_server() in this line to allow customisation when adding esquisse to shiny apps:

https://github.com/emilopezcano/esquisse/blob/3dc09ef43e97a35292c209917ecf395aecfb5ead/R/module-controls.R#L293C15-L293C15

I will send a pull request for your review

bblank70 commented 8 months ago

It is a bit of a hacky fix, but you can edit the functionality of the drop_id function using trace(). drop_id() contains the fixed integer value of 50 that is referred to above. You should probably limit this to a reasonable value based on your distinct values you would expect.

trace(datamods::drop_id, edit=TRUE)