matrix - Represent similarities between lists in R -
i have lot of lists containing different quantities of nominal elements. want compare every list every other list , every combination count how many elements 2 lists share. no statistician imagine outcome represented easiest in matrix.
list1=["joe","hanna","alice"] list2=["martin","ted","joe"] list3=["hanna","ted","joe"]
afterwards represent outcome graphically, maybe using heatmap or cluster representation.
can give me hints how using r? else representation? lot!
you can use crossprod
, table
, , stack
(assuming data in form twl shared):
data <- list(list1=c("joe","hanna","alice"), list2=c("martin","ted","joe"), list3=c("hanna","ted","joe")) crossprod(table(stack(data))) # ind # ind list1 list2 list3 # list1 3 1 2 # list2 1 3 2 # list3 2 2 3
wrap in heatmap
if you're looking heatmap :-)
Comments
Post a Comment