Skip to contents

This method zooms in on details of an object x based on an item y. When x is of class slma (currently the only supported class), y must be one of the lexical markers described in it.

Usage

details(x, y, ...)

# S3 method for slma
details(x, y, shorten_names = TRUE, ...)

Arguments

x

An object containing global statistics for a collection of linguistic units, such as an object of class slma.

y

A character vector of length one representing one linguistic item.

...

Additional arguments.

shorten_names

Logical. If TRUE, filenames in the rownames are shortened with short_names().

Value

An object with details. When x is of class slma, the class of the output is details.slma, namely a list with the following items:

  • summary: The row of x$scores corresponding to y.

  • scores (what is printed by default), a dataframe with one row per pair of documents in the slma and the frequencies and association scores of the chosen item as columns.

  • item: the value of y.

  • sig_cutoff and small_pos, as defined in slma.

Examples

a_corp <- get_fnames(system.file("extdata", "cleveland", package = "mclm"))
b_corp <- get_fnames(system.file("extdata", "roosevelt", package = "mclm"))
slma_ex <- slma(a_corp, b_corp, keep_intermediate = TRUE)
#> building global frequency list for x
#> ....
#> building separate frequency lists for each document
#> ....
#> .....
#> calculating assoc scores
#> ....................
#> calculating stability measures
#> done

gov <- details(slma_ex, "government")
gov$summary
#>            S_abs S_nrm S_att S_rep    S_lor   lor_min  lor_max    lor_sd
#> government    13  0.65    13     0 1.112098 0.7850339 3.172484 0.7982415

# A bit of tidy manipulation to shorten filenames
if (require("dplyr") && require("tidyr")) {
  as_tibble(gov, rownames = "files") %>% 
     tidyr::separate(files, into = c("file_A", "file_B"), sep = "--") %>% 
     dplyr::mutate(dplyr::across(dplyr::starts_with("file"), short_names))
} 
#> Loading required package: dplyr
#> 
#> Attaching package: ‘dplyr’
#> The following object is masked from ‘package:mclm’:
#> 
#>     as_data_frame
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
#> Loading required package: tidyr
#> # A tibble: 20 × 12
#>    file_A       file_B     a     b     c     d      G   sig   dir dir_sig log_OR
#>    <chr>        <chr>  <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>   <dbl>  <dbl>
#>  1 cleveland_s… roose…    16  1676    15  9761 23.2       1     1       1  1.83 
#>  2 cleveland_s… roose…    16  1676     0   309  2.92      1     1      NA  1.81 
#>  3 cleveland_s… roose…    16  1676     0  1212 14.3       1     1       1  3.17 
#>  4 cleveland_s… roose…    16  1676    51 19558 15.9       1     1       1  1.30 
#>  5 cleveland_s… roose…    16  1676     5  2607 11.9       1     1       1  1.60 
#>  6 cleveland_s… roose…    10  1722    15  9761  9.14      1     1       1  1.33 
#>  7 cleveland_s… roose…    10  1722     0   309  1.28      1     1      NA  1.33 
#>  8 cleveland_s… roose…    10  1722     0  1212  7.98      1     1       1  2.69 
#>  9 cleveland_s… roose…    10  1722    51 19558  4.45      1     1       1  0.801
#> 10 cleveland_s… roose…    10  1722     5  2607  4.40      1     1       1  1.11 
#> 11 cleveland_s… roose…   113 19765    15  9761 31.3       1     1       1  1.31 
#> 12 cleveland_s… roose…   113 19765     0   309  1.27      1     1      NA  1.27 
#> 13 cleveland_s… roose…   113 19765     0  1212  9.91      1     1       1  2.63 
#> 14 cleveland_s… roose…   113 19765    51 19558 23.3       1     1       1  0.785
#> 15 cleveland_s… roose…   113 19765     5  2607  8.07      1     1       1  1.09 
#> 16 cleveland_s… roose…     4   823    15  9761  3.30      1     1      NA  1.15 
#> 17 cleveland_s… roose…     4   823     0   309  0.915     1     1      NA  1.22 
#> 18 cleveland_s… roose…     4   823     0  1212  5.40      1     1       1  2.58 
#> 19 cleveland_s… roose…     4   823    51 19558  1.21      1     1      NA  0.623
#> 20 cleveland_s… roose…     4   823     5  2607  1.79      1     1      NA  0.930
#> # … with 1 more variable: log_OR_sig <dbl>