You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using qtable with character variables it would be a nice feature if the row and column splits are ordered alphabetically. This would help improve readability of the table with multiple categories. Also this would follow the behaviour of dplyr::count.
> library(rtables)
Loading required package: formatters
Loading required package: magrittr
> library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
>
> set.seed(123)
> tmp <- data.frame(
+ x = rep("x", 50),
+ y = sample(letters[1:5], size = 50, replace = TRUE, prob = c(0.1, 0.2, 0.3, 0.35, 0.05)),
+ stringsAsFactors = FALSE
+ )
>
> # Categories are not sorted:
> qtable(tmp, "y")
count all obs
(N=50)
———————————————
d 17
b 8
c 14
a 7
e 4
>
> # dplyr sorts:
> tmp %>% count(y)
y n
1 a 7
2 b 8
3 c 14
4 d 17
5 e 4
Code of Conduct
I agree to follow this project's Code of Conduct.
Contribution Guidelines
I agree to follow this project's Contribution Guidelines.
Security Policy
I agree to follow this project's Security Policy.
The text was updated successfully, but these errors were encountered:
This makes sense in isolation but I'm not sure it does within the larger scheme of things, because the rtables framework as a whole matches what happens now (implicit levels of character vectors are ordered by their first appearance in the full dataset, and then fixed in that order regardless of faceting hierarchy).
So while i think this would be nice for qtable and match it's purpose well, I'm not sure it's behavior should diverge from the core tabulation engine, and changing that that might be desirable but would be a fairly large breaking change we would need to think hard before implementing.
Feature description
When using
qtable
with character variables it would be a nice feature if the row and column splits are ordered alphabetically. This would help improve readability of the table with multiple categories. Also this would follow the behaviour ofdplyr::count
.Code of Conduct
Contribution Guidelines
Security Policy
The text was updated successfully, but these errors were encountered: