This function creates a co-occurrence matrix based on one or more coded sources. Optionally, it plots a heatmap, simply by calling the stats::heatmap() function on that matrix.

create_cooccurrence_matrix(
  x,
  codes = x$convenience$codingLeaves,
  plotHeatmap = FALSE
)

Arguments

x

The parsed source(s) as provided by rock::parse_source or rock::parse_sources.

codes

The codes to include; by default, takes all codes.

plotHeatmap

Whether to plot the heatmap.

Value

The co-occurrence matrix; a matrix.

Examples

### Get path to example source examplePath <- system.file("extdata", package="rock"); ### Parse all example sources in that directory parsedExamples <- rock::parse_sources(examplePath); ### Create cooccurrence matrix rock::create_cooccurrence_matrix(parsedExamples);
#> att_ins_eval bla2 bla3 chairs childCode1 childCode2 childCode3 #> att_ins_eval 1 0 0 0 0 0 0 #> bla2 0 1 0 0 0 0 0 #> bla3 0 0 1 0 0 0 0 #> chairs 0 0 0 1 0 0 0 #> childCode1 0 0 0 0 2 1 0 #> childCode2 0 0 0 0 1 1 0 #> childCode3 0 0 0 0 0 0 1 #> childCode4 0 0 0 0 0 0 0 #> childCode5 0 0 0 0 0 0 0 #> flups 0 1 0 0 0 0 0 #> grandchildCode1 0 0 0 0 0 0 0 #> grandchildCode2 0 0 0 0 0 0 0 #> grandchildCode3 0 0 0 0 0 0 0 #> grandchildCode4 0 0 0 0 0 0 0 #> grandchildCode5 0 0 0 0 0 0 0 #> grandchildCode6 0 0 0 0 0 0 0 #> grandchildCode7 0 0 0 0 0 0 0 #> hairy 0 0 0 0 0 0 0 #> inducChild1 0 0 0 0 0 0 0 #> inducChild2 0 0 0 0 0 0 0 #> inducChild3 0 0 0 0 0 0 0 #> inducChild4 0 0 0 0 0 0 0 #> inducChild5 0 0 0 0 0 0 0 #> internet 0 0 0 1 0 0 0 #> love 0 0 0 0 0 0 0 #> oaken_chests 0 0 0 0 0 0 0 #> people 0 0 0 0 0 0 0 #> siamese 0 0 0 0 0 0 0 #> someOtherCode 0 0 0 0 0 0 1 #> subbla 0 0 0 0 0 0 0 #> subbla2 0 0 0 0 0 0 0 #> tables 1 0 0 0 0 0 0 #> Topic1 0 0 0 0 0 0 0 #> Topic2 0 0 0 0 0 0 0 #> childCode4 childCode5 flups grandchildCode1 grandchildCode2 #> att_ins_eval 0 0 0 0 0 #> bla2 0 0 1 0 0 #> bla3 0 0 0 0 0 #> chairs 0 0 0 0 0 #> childCode1 0 0 0 0 0 #> childCode2 0 0 0 0 0 #> childCode3 0 0 0 0 0 #> childCode4 1 0 0 0 0 #> childCode5 0 1 0 0 0 #> flups 0 0 2 0 0 #> grandchildCode1 0 0 0 1 0 #> grandchildCode2 0 0 0 0 3 #> grandchildCode3 0 0 0 0 0 #> grandchildCode4 0 0 0 0 0 #> grandchildCode5 0 0 0 0 0 #> grandchildCode6 0 0 0 0 0 #> grandchildCode7 0 0 0 0 0 #> hairy 0 0 0 0 0 #> inducChild1 0 0 0 0 0 #> inducChild2 0 0 0 0 0 #> inducChild3 0 0 0 0 0 #> inducChild4 0 0 0 0 0 #> inducChild5 0 0 0 0 0 #> internet 0 0 0 0 0 #> love 0 0 0 0 0 #> oaken_chests 0 0 0 0 0 #> people 0 0 0 0 0 #> siamese 0 0 0 0 0 #> someOtherCode 0 0 0 0 0 #> subbla 0 0 0 0 0 #> subbla2 0 0 0 0 0 #> tables 0 0 0 0 0 #> Topic1 0 0 0 0 0 #> Topic2 0 0 0 0 0 #> grandchildCode3 grandchildCode4 grandchildCode5 grandchildCode6 #> att_ins_eval 0 0 0 0 #> bla2 0 0 0 0 #> bla3 0 0 0 0 #> chairs 0 0 0 0 #> childCode1 0 0 0 0 #> childCode2 0 0 0 0 #> childCode3 0 0 0 0 #> childCode4 0 0 0 0 #> childCode5 0 0 0 0 #> flups 0 0 0 0 #> grandchildCode1 0 0 0 0 #> grandchildCode2 0 0 0 0 #> grandchildCode3 1 0 0 0 #> grandchildCode4 0 1 0 0 #> grandchildCode5 0 0 1 0 #> grandchildCode6 0 0 0 1 #> grandchildCode7 0 0 0 0 #> hairy 0 0 0 0 #> inducChild1 0 0 0 0 #> inducChild2 0 0 0 0 #> inducChild3 0 0 0 0 #> inducChild4 0 0 0 0 #> inducChild5 0 0 0 0 #> internet 0 0 0 0 #> love 0 0 0 0 #> oaken_chests 0 0 0 0 #> people 0 0 0 0 #> siamese 0 0 0 0 #> someOtherCode 0 0 0 0 #> subbla 0 0 0 0 #> subbla2 0 0 0 0 #> tables 0 0 0 0 #> Topic1 0 0 0 0 #> Topic2 0 0 0 0 #> grandchildCode7 hairy inducChild1 inducChild2 inducChild3 #> att_ins_eval 0 0 0 0 0 #> bla2 0 0 0 0 0 #> bla3 0 0 0 0 0 #> chairs 0 0 0 0 0 #> childCode1 0 0 0 0 0 #> childCode2 0 0 0 0 0 #> childCode3 0 0 0 0 0 #> childCode4 0 0 0 0 0 #> childCode5 0 0 0 0 0 #> flups 0 0 0 0 0 #> grandchildCode1 0 0 0 0 0 #> grandchildCode2 0 0 0 0 0 #> grandchildCode3 0 0 0 0 0 #> grandchildCode4 0 0 0 0 0 #> grandchildCode5 0 0 0 0 0 #> grandchildCode6 0 0 0 0 0 #> grandchildCode7 1 0 0 0 0 #> hairy 0 1 0 0 0 #> inducChild1 0 0 3 0 0 #> inducChild2 0 0 0 1 0 #> inducChild3 0 0 0 0 4 #> inducChild4 0 0 1 0 0 #> inducChild5 0 0 0 0 0 #> internet 0 0 0 0 0 #> love 0 1 0 0 0 #> oaken_chests 0 0 0 0 0 #> people 0 0 0 0 0 #> siamese 0 1 0 0 0 #> someOtherCode 0 0 0 0 0 #> subbla 0 0 0 0 0 #> subbla2 0 0 0 0 0 #> tables 0 0 0 0 0 #> Topic1 0 0 0 0 0 #> Topic2 0 0 0 0 0 #> inducChild4 inducChild5 internet love oaken_chests people #> att_ins_eval 0 0 0 0 0 0 #> bla2 0 0 0 0 0 0 #> bla3 0 0 0 0 0 0 #> chairs 0 0 1 0 0 0 #> childCode1 0 0 0 0 0 0 #> childCode2 0 0 0 0 0 0 #> childCode3 0 0 0 0 0 0 #> childCode4 0 0 0 0 0 0 #> childCode5 0 0 0 0 0 0 #> flups 0 0 0 0 0 0 #> grandchildCode1 0 0 0 0 0 0 #> grandchildCode2 0 0 0 0 0 0 #> grandchildCode3 0 0 0 0 0 0 #> grandchildCode4 0 0 0 0 0 0 #> grandchildCode5 0 0 0 0 0 0 #> grandchildCode6 0 0 0 0 0 0 #> grandchildCode7 0 0 0 0 0 0 #> hairy 0 0 0 1 0 0 #> inducChild1 1 0 0 0 0 0 #> inducChild2 0 0 0 0 0 0 #> inducChild3 0 0 0 0 0 0 #> inducChild4 3 0 0 0 0 0 #> inducChild5 0 1 0 0 0 0 #> internet 0 0 2 0 0 0 #> love 0 0 0 1 0 0 #> oaken_chests 0 0 0 0 1 1 #> people 0 0 0 0 1 3 #> siamese 0 0 0 1 0 0 #> someOtherCode 0 0 0 0 0 0 #> subbla 0 0 0 0 0 0 #> subbla2 0 0 0 0 0 0 #> tables 0 0 0 0 0 1 #> Topic1 0 0 0 0 0 0 #> Topic2 0 0 0 0 0 0 #> siamese someOtherCode subbla subbla2 tables Topic1 Topic2 #> att_ins_eval 0 0 0 0 1 0 0 #> bla2 0 0 0 0 0 0 0 #> bla3 0 0 0 0 0 0 0 #> chairs 0 0 0 0 0 0 0 #> childCode1 0 0 0 0 0 0 0 #> childCode2 0 0 0 0 0 0 0 #> childCode3 0 1 0 0 0 0 0 #> childCode4 0 0 0 0 0 0 0 #> childCode5 0 0 0 0 0 0 0 #> flups 0 0 0 0 0 0 0 #> grandchildCode1 0 0 0 0 0 0 0 #> grandchildCode2 0 0 0 0 0 0 0 #> grandchildCode3 0 0 0 0 0 0 0 #> grandchildCode4 0 0 0 0 0 0 0 #> grandchildCode5 0 0 0 0 0 0 0 #> grandchildCode6 0 0 0 0 0 0 0 #> grandchildCode7 0 0 0 0 0 0 0 #> hairy 1 0 0 0 0 0 0 #> inducChild1 0 0 0 0 0 0 0 #> inducChild2 0 0 0 0 0 0 0 #> inducChild3 0 0 0 0 0 0 0 #> inducChild4 0 0 0 0 0 0 0 #> inducChild5 0 0 0 0 0 0 0 #> internet 0 0 0 0 0 0 0 #> love 1 0 0 0 0 0 0 #> oaken_chests 0 0 0 0 0 0 0 #> people 0 0 0 0 1 0 0 #> siamese 1 0 0 0 0 0 0 #> someOtherCode 0 1 0 0 0 0 0 #> subbla 0 0 1 0 0 0 0 #> subbla2 0 0 0 1 0 0 0 #> tables 0 0 0 0 2 0 0 #> Topic1 0 0 0 0 0 1 0 #> Topic2 0 0 0 0 0 0 1