ropensci / visdat

Preliminary Exploratory Visualisation of Data
https://docs.ropensci.org/visdat/
Other
450 stars 47 forks source link

Example: vis_expect(airquality, ~.x >= 25) shows plot with wrong T/F colors... #90

Closed sfd99 closed 5 years ago

sfd99 commented 6 years ago

The Problem:

In your example code:

vis_expect(airquality, ~.x >= 25) seems to invert the TRUE/FALSE colors in the plot. head(airquality) Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 2 36 118 8.0 72 5 2 3 12 149 12.6 74 5 3 4 18 313 11.5 62 5 4 5 NA NA 14.3 56 5 5 6 28 NA 14.9 66 5 6

Yet, the plot of:

vis_expect(airquality, ~.x >= 25) shows exactly the wrong (opposite) T/F colors...

What am I doing wrong? Love VISDAT! HELP!... SFd99 confused in San Francisco.

njtierney commented 6 years ago

Thanks for filing an issue!

I think that this is a bug, I'll look into this soon and get back to you.

sfd99 commented 6 years ago

NJ -any news about the fix for this issue? Have not heard from you in a while...

Thanks for any update to this inverted T/F color problem! :-) (ie: airquality example shows colors as True values which are False and vv!)... pls, do see my 1st message above and try the airquality example with visdat...

[using latest versions of Rstudio, R, Ubuntu linux]

samanthalazaro commented 5 years ago

Hello, I think I know where the error may be. In the vis-expect.R scrip, inside the expect_guide_label function:

`else {

# calculate rounded percentages
p_expect_false <- round(p_expect, 1)
p_expect_true <- round(100 - p_expect,1)

# create the labels
p_expect_false_lab <- paste("FALSE \n(",
                            p_expect_false,
                            "%)",
                            sep = "")

p_expect_true_lab <- paste("TRUE \n(",
                           p_expect_true,
                           "%)",
                           sep = "")

}` I tried the code and I think it should be:

 p_expect_false_lab <- paste("TRUE \n(",
                                p_expect_false,
                                "%)",
                                sep = "")

    p_expect_true_lab <- paste("FALSE \n(",
                               p_expect_true,
                               "%)",
                               sep = "")

I don't know if this change will cause in any conflict in the code so I'm not making a pull request... Tell me if it works for you.

njtierney commented 5 years ago

Thank you very much @samanthalazaro ! I really appreciate you finding this error! :)