x <- tibble::tribble(
~voter_id, ~species, ~food, ~ranking,
1, "Rabbit", "Apple", 1,
1, "Rabbit", "Banana", 2,
1, "Rabbit", "Carrot", 3,
2, "Monkey", "Banana", 1,
2, "Monkey", "Apple", 2,
2, "Monkey", "Carrot", 3
) |>
long_preferences(
food_preference,
id_cols = voter_id,
item_col = food,
rank_col = ranking
) |>
dplyr::pull(food_preference) |>
adjacency()
Run the code above in your browser using DataLab