Skip to content

Commit

Permalink
Follow changes in nexus
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Oct 17, 2024
1 parent 0b86f90 commit 1f7cf19
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/coda.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ coda_server <- function(id, x) {
req(clean())
if (nexus::any_assigned(clean())) {
tbl <- data.frame(group = nexus::groups(clean()), clean())
gt <- gt::gt(tbl, groupname_col="group", rownames_to_stub = TRUE)
gt <- gt::gt(tbl, groupname_col = "group", rownames_to_stub = TRUE)
} else {
gt <- clean() |>
as.data.frame() |>
Expand Down
3 changes: 1 addition & 2 deletions R/coda_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ coda_outliers_server <- function(id, x) {

run_with_notification(
{
nexus::outliers(
nexus::detect_outlier(
x(),
groups = nexus::groups(x()),
method = input$method,
quantile = input$quantile
)
Expand Down
31 changes: 30 additions & 1 deletion R/coda_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,23 @@ coda_plot_ui <- function(id) {
inputId = ns("decreasing"),
label = "Decreasing row order",
value = FALSE
)
),
hr(),
checkboxInput(
inputId = ns("select_major"),
label = "Major elements",
value = TRUE
),
checkboxInput(
inputId = ns("select_minor"),
label = "Minor elements",
value = TRUE
),
checkboxInput(
inputId = ns("select_trace"),
label = "Trace elements",
value = TRUE
),
), # sidebar
output_plot(
id = ns("plot"),
Expand Down Expand Up @@ -70,8 +86,21 @@ coda_plot_server <- function(id, x) {
req(x())

col <- khroma::color(input$color_qualitative)

elements <- logical(ncol(x()))
is_major <- nexus::is_element_major(x())
is_minor <- nexus::is_element_minor(x())
is_trace <- nexus::is_element_trace(x())

elements[which(is_major)] <- input$select_major
elements[which(is_minor)] <- input$select_minor
elements[which(is_trace)] <- input$select_trace

if (!any(elements)) elements <- NULL

nexus::barplot(
height = x(),
select = elements,
order_columns = input$order_columns,
order_rows = input$order_rows,
decreasing = input$decreasing,
Expand Down
6 changes: 3 additions & 3 deletions R/coda_statistics.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ coda_summary_server <- function(id, x) {
## Metric variance by group
if (nexus::any_assigned(x())) {
index <- nexus::groups(x())
s <- nexus::aggregate(x(), by = index, FUN = nexus::metric_var)
s <- nexus::aggregate(x(), by = index, FUN = nexus::variance_total)
} else {
m <- nexus::metric_var(x())
m <- nexus::variance_total(x())
s <- matrix(m, nrow = 1, dimnames = list("", NULL))
}
colnames(s) <- c("metric variance")
Expand Down Expand Up @@ -234,7 +234,7 @@ coda_summary_server <- function(id, x) {
## Download -----
output$download <- export_multiple(
location = data_loc,
spread = data_spread,
# spread = data_spread,
quantiles = data_quant,
covariance = data_cov,
variation = data_var,
Expand Down

0 comments on commit 1f7cf19

Please sign in to comment.