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

rearrange(absolute = TRUE) doesn't do anything #167

Open
jmbarbone opened this issue Dec 13, 2022 · 0 comments · May be fixed by #168
Open

rearrange(absolute = TRUE) doesn't do anything #167

jmbarbone opened this issue Dec 13, 2022 · 0 comments · May be fixed by #168

Comments

@jmbarbone
Copy link

jmbarbone commented Dec 13, 2022

The problem

abs(m) isn't assigned?

corrr/R/cor_df.R

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

@jmbarbone jmbarbone linked a pull request Dec 13, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant