insightsengineering / insightsengineering/teal.modules.general

[Bug]: The order of statistics in `tm_outliers` summary table is random

Open
#735 2 comments 0 reactions 0 assignees View on GitHub
bug core
Dominant language
R
Stars
16
Forks
23
PR merge metrics
No merged PRs in 30d

Description

### What happened?

The order of statistics in a drop-down menu is as follows

```r
[1] "Qn1" "Qn2" "Qn3" "Qc1" "Qc2" "Qc3" "Mn1" "Mn2" "Mn3" "Mc1" "Mc2" "Mc3"
```

but the order that is displayed is a bit random

```r
Qn1 Qn2 Qn3 Qc1 Qc3 Qc2 Mn3 Mn2 Mn1 Mc2 Mc3 Mc1
```

image

Code to reproduce

```r
library(teal)
library(teal.modules.general)
app_driver_tm_outlier <- function() {
data <- teal.data::teal_data()
data <- within(data, {
CO2 <- CO2 # nolint: object_name
CO2[["primary_key"]] <- seq_len(nrow(CO2))
})
teal.data::datanames(data) <- "CO2"
teal.data::join_keys(data) <- teal.data::join_keys(join_key("CO2", "CO2", "primary_key"))

vars <- teal.transform::choices_selected(teal.transform::variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")))

init_teal_app_driver(
data = data,
modules = tm_outliers(
outlier_var = list(
teal.transform::data_extract_spec(
dataname = "CO2",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(data[["CO2"]], c("conc", "uptake")),
selected = "uptake",
multiple = FALSE,
fixed = FALSE
)
)
),
categorical_var = list(
teal.transform::data_extract_spec(
dataname = "CO2",
filter = teal.transform::filter_spec(
vars = vars,
choices = teal.transform::value_choices(data[["CO2"]], vars$selected),
selected = teal.transform::value_choices(data[["CO2"]], vars$selected),
multiple = TRUE
)
)
),
ggplot2_args = list(
teal.widgets::ggplot2_args(
labs = list(subtitle = "Plot generated by Outliers Module")
)
)
)
)
}
app_driver <- app_driver_tm_outlier()
app_driver$open_url()
```

### sessionInfo()

_No response_

### Relevant log output

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [X] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [X] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.