Skip to content

Commit 37936d6

Browse files
committed
fix(#30488): preserve key-value correlation column names
1 parent 59d7da9 commit 37936d6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

R/stats_wrapper.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ as_numeric_correlation_matrix <- function(df) {
283283
} else {
284284
x
285285
}
286-
})))
286+
}), check.names = FALSE))
287287
}
288288

289289
as_hetcor_data_frame <- function(df, force_ordinal = FALSE) {
@@ -304,7 +304,9 @@ do_cor_internal <- function(mat, use, method, diag, output_cols, na.rm) {
304304
# but I'm hoping this might still help align the result between Mac and Windows if there are ties in the mean correlations.
305305
# We use stringr::str_sort() as opposed to base sort() so that the result is consistent on Windows too.
306306
sorted_colnames <- stringr::str_sort(colnames(mat))
307-
mat <- as.data.frame(mat[, sorted_colnames, drop = FALSE])
307+
# `as.data.frame.matrix()` otherwise changes numeric matrix column names such
308+
# as "1" to "X1", breaking the key-value correlation output contract.
309+
mat <- as.data.frame(mat[, sorted_colnames, drop = FALSE], check.names = FALSE)
308310
method <- resolve_correlation_method(mat, method)
309311

310312
# Create a matrix of P-values for Analytics View case.

0 commit comments

Comments
 (0)