Skip to content

Commit c03994e

Browse files
hidekojicursoragent
andcommitted
fix(pca): refresh analysis_conditions metrics and copy for #37268
Rename Rows Used/Variables Used, drop Rows vs Variables, show None when no variables are excluded, and update Description strings for the PCA report. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1580a0f commit c03994e

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

R/prcomp.R

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -338,40 +338,40 @@ tidy.prcomp_exploratory <- function(x, type="variances", n_sample=NULL, pretty.n
338338
normalized <- isTRUE(x$normalize_data)
339339
variables_used <- length(d$variable_sd)
340340
excluded_names <- d$excluded_variables
341-
excluded_display <- if (length(excluded_names) == 0) "-" else paste(excluded_names, collapse = ", ")
341+
# #37268: show "None" (JA: なし) when nothing was excluded, not "-".
342+
excluded_display <- if (length(excluded_names) == 0) "None" else paste(excluded_names, collapse = ", ")
342343
excluded_pct <- d$excluded_row_rate * 100
343344
scale_ratio <- d$scale_ratio
344345
scale_display <- if (is.na(scale_ratio)) "-" else format(round(scale_ratio, 1), nsmall = 1)
345346
scale_status <- if (!normalized && is.finite(scale_ratio) && scale_ratio >= cfg$scale_ratio_warning) "scale_warning" else "ok"
347+
# #37268: rename Rows Used / Variables Used; drop redundant Rows vs Variables row;
348+
# refresh Description copy (and English-canonical strings for the client translator).
346349
res <- tibble::tibble(
347-
Metric = c("Rows Used", "Rows Excluded", "Variables Used", "Excluded Variables",
348-
"Normalization", "SD Ratio (Max/Min)", "Rows vs Variables"),
350+
Metric = c("Number of Rows", "Rows Excluded", "Number of Variables", "Excluded Variables",
351+
"Normalization", "SD Ratio (Max/Min)"),
349352
Value = c(
350353
as.character(d$analyzed_row_count),
351354
paste0(d$excluded_row_count, " (", format(round(excluded_pct, 1), nsmall = 1), "%)"),
352355
as.character(variables_used),
353356
excluded_display,
354357
if (normalized) "Yes" else "No",
355-
scale_display,
356-
paste0(d$analyzed_row_count, " rows / ", variables_used, " variables")
358+
scale_display
357359
),
358360
Description = c(
359-
"Number of rows used after removing missing values.",
361+
"Number of rows used in the analysis.",
360362
"Number and rate of rows removed because of missing values.",
361363
"Number of variables used in the analysis.",
362-
"Variables dropped before analysis because they had only NA or a single value.",
363-
"Whether variables were scaled to unit variance before analysis.",
364-
"Ratio of the largest to the smallest variable standard deviation.",
365-
"Number of rows compared with the number of variables."
364+
"Variables dropped before analysis because they were all missing or had only one unique value.",
365+
"Whether variables were standardized before analysis.",
366+
"Ratio of the maximum to the minimum standard deviation across all variables."
366367
),
367368
status = c(
368-
"ok",
369+
if (d$analyzed_row_count <= variables_used) "few_rows" else "ok",
369370
if (d$excluded_row_rate >= cfg$na_exclusion_warning) "high_na_exclusion" else "ok",
370371
"ok",
371372
if (length(excluded_names) == 0) "na" else "ok",
372373
"ok",
373-
scale_status,
374-
if (d$analyzed_row_count <= variables_used) "few_rows" else "ok"
374+
scale_status
375375
)
376376
)
377377
}

tests/testthat/test_prcomp.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,15 @@ test_that("new report tidy types return expected columns and tokens", {
9393
model_df <- mtcars %>% do_prcomp(mpg, cyl, disp, hp, drat, wt)
9494
res <- model_df %>% tidy_rowwise(model, type = "analysis_conditions")
9595
expect_equal(colnames(res), c("Metric", "Value", "Description", "status"))
96-
expect_true(all(c("Rows Used","Variables Used","Normalization","SD Ratio (Max/Min)") %in% res$Metric))
96+
expect_true(all(c("Number of Rows","Number of Variables","Normalization","SD Ratio (Max/Min)") %in% res$Metric))
97+
expect_false("Rows vs Variables" %in% res$Metric)
98+
expect_false("Rows Used" %in% res$Metric)
99+
expect_false("Variables Used" %in% res$Metric)
100+
# #37268: empty excluded-variables cell is "None" (JA: なし), not "-".
101+
excluded_row <- res[res$Metric == "Excluded Variables", , drop = FALSE]
102+
if (nrow(excluded_row) == 1 && identical(excluded_row$status, "na")) {
103+
expect_equal(excluded_row$Value, "None")
104+
}
97105
res <- model_df %>% tidy_rowwise(model, type = "parallel_screeplot")
98106
expect_equal(colnames(res), c("Component", "Eigenvalue", "Random Data Eigenvalue"))
99107
res <- model_df %>% tidy_rowwise(model, type = "variances_judged")

0 commit comments

Comments
 (0)