-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
The problem
abs(m)
isn't assigned?
Lines 39 to 46 in bd5841d
rearrange.cor_df <- function(x, method = "PCA", absolute = TRUE) { | |
# Convert to original matrix | |
m <- as_matrix(x, diagonal = 1) | |
if (absolute) abs(m) | |
if (method %in% c("BEA", "BEA_TSP", "PCA", "PCA_angle")) { |
Reproducible example
library(corrr)
df <- data.frame(
x = 1:10,
y = -c(1:10),
z = 1:10
)
cdf <- correlate(df)
#> Correlation computed with
#> • Method: 'pearson'
#> • Missing treated using: 'pairwise.complete.obs'
rearrange(cdf, absolute = TRUE) # shouldn't change order
#> # A tibble: 3 × 4
#> term x z y
#> <chr> <dbl> <dbl> <dbl>
#> 1 x NA 1 -1
#> 2 z 1 NA -1
#> 3 y -1 -1 NA
rearrange(cdf, absolute = FALSE) # expected (because not assigned)
#> # A tibble: 3 × 4
#> term x z y
#> <chr> <dbl> <dbl> <dbl>
#> 1 x NA 1 -1
#> 2 z 1 NA -1
#> 3 y -1 -1 NA
cdf[2:4] <- lapply(cdf[2:4], abs)
rearrange(cdf)
#> # A tibble: 3 × 4
#> term x y z
#> <chr> <dbl> <dbl> <dbl>
#> 1 x NA 1 1
#> 2 y 1 NA 1
#> 3 z 1 1 NA
Created on 2022-12-13 with reprex v2.0.2
ahrensmaike
Metadata
Metadata
Assignees
Labels
No labels