Datasets
category <- c('food','food','food','food','food','food',
'edibles','edibles','edibles','edibles', 'edibles')
location <- c('houston, TX', 'houston, TX', 'las vegas, NV', 'las vegas, NV', 'philadelphia, PA',
'philadelphia, PA', 'austin, TX', 'austin, TX', 'charlotte, NC', 'charlotte, NC', 'charlotte, NC')
item <- c('apple', 'banana', 'apple', 'pear', 'apple',
'pear', 'pear', 'apple', 'apple', 'pear', 'banana')
food_data <- data.frame(cbind(category, location, item), stringsAsFactors = FALSE)
food_data
## category location item
## 1 food houston, TX apple
## 2 food houston, TX banana
## 3 food las vegas, NV apple
## 4 food las vegas, NV pear
## 5 food philadelphia, PA apple
## 6 food philadelphia, PA pear
## 7 edibles austin, TX pear
## 8 edibles austin, TX apple
## 9 edibles charlotte, NC apple
## 10 edibles charlotte, NC pear
## 11 edibles charlotte, NC banana
Pairs
## category location apple banana pear
## 1 edibles austin, TX 1 0 1
## 2 edibles charlotte, NC 1 1 1
## 3 food houston, TX 1 1 0
## 4 food las vegas, NV 1 0 1
## 5 food philadelphia, PA 1 0 1
## Warning: `as_data_frame()` is deprecated, use `as_tibble()` (but mind the new semantics).
## This warning is displayed once per session.
## Note: Using an external vector in selections is ambiguous.
## ℹ Use `all_of(.x)` instead of `.x` to silence this message.
## ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This message is displayed once per session.
## Note: Using an external vector in selections is ambiguous.
## ℹ Use `all_of(.y)` instead of `.y` to silence this message.
## ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This message is displayed once per session.
## # A tibble: 3 x 3
## V1 V2 count
## <chr> <chr> <int>
## 1 apple banana 2
## 2 apple pear 4
## 3 banana pear 1
## # A tibble: 3 x 2
## Pair count
## <chr> <int>
## 1 apple_banana 2
## 2 apple_pear 4
## 3 banana_pear 1