Summaries two columns information

summ_2col(df, from = 1, to = 2, count = 3, direct = FALSE)

Arguments

df

data.frame

from

first column name or index

to

second column name or index

count

(optional) weight column, if no, each equal to 1

direct

consider direct? default: FALSE

Value

data.frame

Examples

test <- data.frame(
  a = sample(letters[1:4], 10, replace = TRUE),
  b = sample(letters[1:4], 10, replace = TRUE)
)
summ_2col(test, direct = TRUE)
#>   a b count
#> 1 a b     1
#> 2 a c     1
#> 3 b a     1
#> 4 b c     1
#> 5 b d     2
#> 6 c a     1
#> 7 c c     2
#> 8 d a     1
summ_2col(test, direct = FALSE)
#>   a b count
#> 1 a b     2
#> 2 a c     2
#> 3 a d     1
#> 4 b c     1
#> 5 b d     2
#> 6 c c     2
if (requireNamespace("circlize")) {
  summ_2col(test, direct = TRUE) %>% pcutils::my_circo()
}
#> Loading required namespace: circlize