corrr
corrr copied to clipboard
`rearrange(absolute = TRUE)` doesn't do anything
The problem
abs(m)
isn't assigned?
https://github.com/tidymodels/corrr/blob/bd5841ddcf7f50d824b188b9e007a6069ab1cce7/R/cor_df.R#L39-L46
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