-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desc does not always reset mfrow after creating plots #49
Comments
This is indeed not a convincing design, which derives from a very early version of DescTools. |
Here is just a reprex of the code by @ajcullum with outputs and plots: library(DescTools)
# With default par() values active
db <- structure(list(Group = structure(sample.int(2, 10, replace=T),
.Label = c("A", "B"), class = "factor"),
Value = sample.int(100, 10, replace=T)),
row.names = c(NA, 10L), class = "data.frame")
# This use of Desc() does *not* cause the error
Desc(db$Value~db$Group) # Gives side-by-side graphs
#> ------------------------------------------------------------------------------
#> db$Value ~ db$Group
#>
#> Summary:
#> n pairs: 10, valid: 10 (100.0%), missings: 0 (0.0%), groups: 2
#>
#>
#> A B
#> mean 44.600 16.000
#> median 59.000 13.000
#> sd 27.682 17.059
#> IQR 37.000 11.000
#> n 5 5
#> np 50.000% 50.000%
#> NAs 0 0
#> 0s 0 0
#>
#> Kruskal-Wallis rank sum test:
#> Kruskal-Wallis chi-squared = 3.1527, df = 1, p-value = 0.0758 # Check the layout afterwards
layout.show(2) # Future graphs will fill the plot area # This (somewhat unusual) call *does* trigger the error
Desc(db$Group~db$Value) # Gives side-by-side graphs
#> ------------------------------------------------------------------------------
#> db$Group ~ db$Value
#>
#> Summary:
#> n pairs: 10, valid: 10 (100.0%), missings: 0 (0.0%), groups: 2
#>
#>
#> A B
#> mean 44.600 16.000
#> median 59.000 13.000
#> sd 27.682 17.059
#> IQR 37.000 11.000
#> n 5 5
#> np 50.000% 50.000%
#> NAs 0 0
#> 0s 0 0
#>
#> Kruskal-Wallis rank sum test:
#> Kruskal-Wallis chi-squared = 3.1527, df = 1, p-value = 0.0758
#>
#>
#>
#>
#>
#> Proportions of db$Group in the quantiles of db$Value:
#>
#> Q1 Q2 Q3 Q4
#> A 33.3% 0.0% 50.0% 100.0%
#> B 66.7% 100.0% 50.0% 0.0%
#> Warning in par(usr): argument 1 does not name a graphical parameter # Check the layout afterwards
layout.show(2) # Future graphs will also be in pairs, side-by-side Created on 2023-02-28 with reprex v2.0.2 |
Is it possible to solve this by using something like |
I think the original issue is solved, but some lines of code should be rewritten to make code more robust, eg in these and some other lines of code may need more attention: Lines 2832 to 2833 in 388487e
Lines 2936 to 2937 in 388487e
Line 3099 in 388487e
I recommend resetting via |
This should also be fixed now. |
When Desc creates output that show multiple graphs per plot(? Unsure of the terminology), it appears to do this by changing par(mfrow()) and layout(). But those settings are not always returned to the default c(1,1) afterward. The result is that later graphs do not fill the plot area.
The demo code below shows the error. I've seen it occur in other uses of Desc() as well, but this happened before I figured out the issue, and so I didn't make note of the particular arguments that triggered it.
Thanks!
The text was updated successfully, but these errors were encountered: