gabor grothendieck ggrothendieckgmailcom thats nice solution small tweak get names time rather applying afterwards sapplylevelsunlistdf functionx crossproddf x simplify false lapplysapplylevelsunlistdf df simplify false crossprod thu aug 7 2008 1003 dan davison wrote lauri nikkinen wrote r users dont know make clear ill give try dataframe like x var1var2var3var4 abba bbcb caaa abcc baca ccbb acab bcac cabc df readtabletextconnectionx headert sep df would like sum combinationsoccurences factor letter case variables produce list occurrence matrices example case occurrence matrix first element list factor look like occulist var1 var2 var3 var4 var1 x 0 1 1 var2 0 x 1 2 var3 1 1 x 1 var4 1 2 1 x b etc two rows var2 var4 think occurmatrices functiondf levels levelsunlistdf ans lapplylevels functionlevel crossproddf level structureans nameslevels dan occurmatricesdf var1 var2 var3 var4 var1 3 0 1 1 var2 0 3 1 2 var3 1 1 3 1 var4 1 2 1 3 b var1 var2 var3 var4 var1 3 1 0 1 var2 1 3 1 1 var3 0 1 3 1 var4 1 1 1 3 c var1 var2 var3 var4 var1 3 1 0 1 var2 1 3 0 1 var3 0 0 3 1 var4 1 1 1 3 dfdfvar2a dfvar4a give advice achieve kind list matrices lauri ______________________________________________ rhelprprojectorg mailing list httpsstatethzchmailmanlistinforhelp please read posting guide httpwwwrprojectorgpostingguidehtml provide commented minimal selfcontained reproducible code view message context httpwwwnabblecomlistof22occurrence22matricestp18870809p18871268html sent r help mailing list archive nabblecom ______________________________________________ rhelprprojectorg mailing list httpsstatethzchmailmanlistinforhelp please read posting guide httpwwwrprojectorgpostingguidehtml provide commented minimal selfcontained reproducible code ______________________________________________ rhelprprojectorg mailing list httpsstatethzchmailmanlistinforhelp please read posting guide httpwwwrprojectorgpostingguidehtml provide commented minimal selfcontained reproducible code thu 07 aug 2008 105715 0400 r list occurrence matrices