crosstab_sdg calculates cross tables (aka contingency tables) of SGSs or systems across hits identified via detect_sdg_systems.

crosstab_sdg(hits, compare = c("systems", "sdgs"), systems = NULL, sdgs = NULL)

Arguments

hits

data frame as returned by detect_sdg_systems. Must include columns document, sdg, system, and hit.

compare

character specifying whether systems or SDGs should be cross tabulated.

systems

character vector specifying the query systems to be cross tabulated. Values must be available in the system column of hits. Defaults to NULL in which case available values are retrieved from hits.

sdgs

numeric vector with integers between 1 and 17 specifying the SDGs to be cross tabluated. Values must be available in the sdg column of hits. Defaults to NULL in which case available values are retrieved from hits.

Value

matrix showing correlation coefficients for all pairs of query systems (if compare = "systems") or SDGs (if compare = "SDGs").

Details

crosstab_sdg determines correlations between either query systems or SDGs. The respectively other dimension will be ignored. Note that correlations between SDGs may vary between query systems.

Examples

# \donttest{
# run sdg detection
hits <- detect_sdg_systems(projects)
#> Running Aurora
#> Running Elsevier
#> Running Auckland
#> Running SIRIS

# create cross table of systems
crosstab_sdg(hits)
#>           Auckland    Aurora  Elsevier     SIRIS
#> Auckland 1.0000000 0.2590583 0.7544995 0.3249410
#> Aurora   0.2590583 1.0000000 0.2434814 0.3028867
#> Elsevier 0.7544995 0.2434814 1.0000000 0.2702591
#> SIRIS    0.3249410 0.3028867 0.2702591 1.0000000

# create cross table of systems
crosstab_sdg(hits, compare = "sdgs")
#>              SDG-01       SDG-02       SDG-03       SDG-04       SDG-05
#> SDG-01  1.000000000 -0.009764754  0.059237226 -0.006885604  0.104430296
#> SDG-02 -0.009764754  1.000000000  0.145704501  0.056974517 -0.005279730
#> SDG-03  0.059237226  0.145704501  1.000000000 -0.005145467  0.023353069
#> SDG-04 -0.006885604  0.056974517 -0.005145467  1.000000000 -0.003722995
#> SDG-05  0.104430296 -0.005279730  0.023353069 -0.003722995  1.000000000
#> SDG-06  0.086736183 -0.006250195 -0.009769492 -0.004407317 -0.002966941
#> SDG-07 -0.010204113  0.076428642 -0.022998943 -0.008195795 -0.005517289
#> SDG-08  0.169410578 -0.009764754 -0.020993780 -0.006885604  0.104430296
#> SDG-09 -0.006563516 -0.007476041 -0.019144453 -0.005271721 -0.003548845
#> SDG-10  0.163412597 -0.016537845  0.039462208  0.120857005  0.188410675
#> SDG-11  0.274225536 -0.014278372 -0.023637132 -0.010068377 -0.006777883
#> SDG-12 -0.006885604 -0.007842908 -0.038342026 -0.005530417 -0.003722995
#> SDG-13 -0.015569858  0.011578744 -0.049167368 -0.012505484 -0.008418507
#> SDG-14  0.048847182  0.040709128 -0.049133820 -0.007087015 -0.004770874
#> SDG-15  0.023243833  0.082225285 -0.043852800 -0.011153749 -0.007508539
#> SDG-16  0.061376125 -0.015632809 -0.051034572 -0.011023456  0.061610130
#> SDG-17 -0.003588680 -0.004087613  0.011736237 -0.002882375 -0.001940373
#>              SDG-06       SDG-07       SDG-08       SDG-09       SDG-10
#> SDG-01  0.086736183 -0.010204113  0.169410578 -0.006563516  0.163412597
#> SDG-02 -0.006250195  0.076428642 -0.009764754 -0.007476041 -0.016537845
#> SDG-03 -0.009769492 -0.022998943 -0.020993780 -0.019144453  0.039462208
#> SDG-04 -0.004407317 -0.008195795 -0.006885604 -0.005271721  0.120857005
#> SDG-05 -0.002966941 -0.005517289  0.104430296 -0.003548845  0.188410675
#> SDG-06  1.000000000 -0.006531419  0.086736183 -0.004201156  0.046024611
#> SDG-07 -0.006531419  1.000000000  0.089836209 -0.007812421 -0.017281955
#> SDG-08  0.086736183  0.089836209  1.000000000  0.070654322  0.056653496
#> SDG-09 -0.004201156 -0.007812421  0.070654322  1.000000000 -0.011116144
#> SDG-10  0.046024611 -0.017281955  0.056653496 -0.011116144  1.000000000
#> SDG-11  0.055656612 -0.014920819  0.151327925  0.097040462  0.077059029
#> SDG-12 -0.004407317  0.240161637  0.140400047 -0.005271721 -0.011661641
#> SDG-13  0.093576002  0.037626564  0.084343668 -0.011920515 -0.026369522
#> SDG-14 -0.005647806 -0.010502594 -0.008823635  0.068305673 -0.014943941
#> SDG-15  0.106548726 -0.016529285  0.060374557 -0.010632010 -0.023519204
#> SDG-16 -0.008784847  0.015323100  0.061376125  0.038365731  0.224516291
#> SDG-17 -0.002297032 -0.004271533 -0.003588680 -0.002747547 -0.006077883
#>              SDG-11       SDG-12       SDG-13       SDG-14       SDG-15
#> SDG-01  0.274225536 -0.006885604 -0.015569858  0.048847182  0.023243833
#> SDG-02 -0.014278372 -0.007842908  0.011578744  0.040709128  0.082225285
#> SDG-03 -0.023637132 -0.038342026 -0.049167368 -0.049133820 -0.043852800
#> SDG-04 -0.010068377 -0.005530417 -0.012505484 -0.007087015 -0.011153749
#> SDG-05 -0.006777883 -0.003722995 -0.008418507 -0.004770874 -0.007508539
#> SDG-06  0.055656612 -0.004407317  0.093576002 -0.005647806  0.106548726
#> SDG-07 -0.014920819  0.240161637  0.037626564 -0.010502594 -0.016529285
#> SDG-08  0.151327925  0.140400047  0.084343668 -0.008823635  0.060374557
#> SDG-09  0.097040462 -0.005271721 -0.011920515  0.068305673 -0.010632010
#> SDG-10  0.077059029 -0.011661641 -0.026369522 -0.014943941 -0.023519204
#> SDG-11  1.000000000  0.040782011  0.092217051  0.066741189  0.030971638
#> SDG-12  0.040782011  1.000000000  0.028834958  0.064498999  0.034936123
#> SDG-13  0.092217051  0.028834958  1.000000000  0.113472022  0.287436788
#> SDG-14  0.066741189  0.064498999  0.113472022  1.000000000  0.057894262
#> SDG-15  0.030971638  0.034936123  0.287436788  0.057894262  1.000000000
#> SDG-16  0.083645528 -0.011023456 -0.003846999 -0.014126131 -0.022232112
#> SDG-17 -0.005247496 -0.002882375 -0.006517682 -0.003693652 -0.005813176
#>              SDG-16       SDG-17
#> SDG-01  0.061376125 -0.003588680
#> SDG-02 -0.015632809 -0.004087613
#> SDG-03 -0.051034572  0.011736237
#> SDG-04 -0.011023456 -0.002882375
#> SDG-05  0.061610130 -0.001940373
#> SDG-06 -0.008784847 -0.002297032
#> SDG-07  0.015323100 -0.004271533
#> SDG-08  0.061376125 -0.003588680
#> SDG-09  0.038365731 -0.002747547
#> SDG-10  0.224516291 -0.006077883
#> SDG-11  0.083645528 -0.005247496
#> SDG-12 -0.011023456 -0.002882375
#> SDG-13 -0.003846999 -0.006517682
#> SDG-14 -0.014126131 -0.003693652
#> SDG-15 -0.022232112 -0.005813176
#> SDG-16  1.000000000 -0.005745270
#> SDG-17 -0.005745270  1.000000000
# }