dreamRs / esquisse

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

Blank values #93

Open rspreafico opened 4 years ago

rspreafico commented 4 years ago

Hi there,

when importing a data frame with some cells being empty, esquisse does not turn these into NAs. Later, filters won't show empty cells as one of the possible levels of factor for filtering. Dataframe rows where one of the cell is empty are automatically removed, because "empty" is not a selectable level of a factor, but it is not NA either.

Thanks

pvictor commented 4 years ago

Yes, "" are ignored, here exactly: https://github.com/dreamRs/esquisse/blob/c432b807ce15ddc5d2e9d92d19d72ba857886b8f/R/module-filterDF.R#L212 How do you suggest to deal with them ? I originally discarded them because "" is not a truthy value for shiny::req.

rspreafico commented 4 years ago

Hi @pvictor , my instinct would be to treat "" as NAs since this is what R typically does when reading CSVs/TSVs and working interactively. That could be the default behavior. However, the import module might have a control (or a parameter) specifying whether "" should instead be a level of a factor. Clearly, that is not an option for numeric and boolean fields - only for characters. That is why I think that defaulting to NA would work best - it would work for numbers and booleans as well. I would not discard these rows though because I think it would be unexpected to a user that some rows are entirely missing from a loaded dataset, maybe because only one field is blank.

That is my guess, please let me know if you think it's ok. Thanks again for being open to this change, very much appreciated! :-)