Skip to content
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

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

Open
3 tasks done
m7pr opened this issue Apr 17, 2024 · 2 comments
Open
3 tasks done

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

m7pr opened this issue Apr 17, 2024 · 2 comments
Labels
bug Something isn't working core

Comments

@m7pr
Copy link
Contributor

m7pr commented Apr 17, 2024

What happened?

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

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

but the order that is displayed is a bit random

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

Code to reproduce

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

  • 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.
@m7pr m7pr added bug Something isn't working core labels Apr 17, 2024
@m7pr
Copy link
Contributor Author

m7pr commented Apr 17, 2024

The order is taken from order of factor levels in the data

> CO2$Plant
 [1] Qn1 Qn1 Qn1 Qn1 Qn1 Qn1 Qn1 Qn2 Qn2
[10] Qn2 Qn2 Qn2 Qn2 Qn2 Qn3 Qn3 Qn3 Qn3
[19] Qn3 Qn3 Qn3 Qc1 Qc1 Qc1 Qc1 Qc1 Qc1
[28] Qc1 Qc2 Qc2 Qc2 Qc2 Qc2 Qc2 Qc2 Qc3
[37] Qc3 Qc3 Qc3 Qc3 Qc3 Qc3 Mn1 Mn1 Mn1
[46] Mn1 Mn1 Mn1 Mn1 Mn2 Mn2 Mn2 Mn2 Mn2
[55] Mn2 Mn2 Mn3 Mn3 Mn3 Mn3 Mn3 Mn3 Mn3
[64] Mc1 Mc1 Mc1 Mc1 Mc1 Mc1 Mc1 Mc2 Mc2
[73] Mc2 Mc2 Mc2 Mc2 Mc2 Mc3 Mc3 Mc3 Mc3
[82] Mc3 Mc3 Mc3
12 Levels: Qn1 < Qn2 < Qn3 < ... < Mc1
> levels(CO2$Plant)
 [1] "Qn1" "Qn2" "Qn3" "Qc1" "Qc3" "Qc2"
 [7] "Mn3" "Mn2" "Mn1" "Mc2" "Mc3" "Mc1"

@m7pr
Copy link
Contributor Author

m7pr commented Apr 17, 2024

will continue the discussion here insightsengineering/teal.transform#213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

No branches or pull requests

1 participant