Skip to contents

This function writes an object of class assoc_scores to a file.

Usage

write_assoc(x, file = "", sep = "\t")

Arguments

x

An object of class assoc_scores.

file

Name of the output file.

sep

Field separator for the output file.

Value

Invisibly, x.

See also

Examples

txt1 <- "we're just two lost souls swimming in a fish bowl,
year after year, running over the same old ground,
what have we found? the same old fears.
wish you were here."
flist1 <- freqlist(txt1, as_text = TRUE)
txt2 <- "picture yourself in a boat on a river
with tangerine dreams and marmelade skies
somebody calls you, you answer quite slowly
a girl with kaleidoscope eyes"
flist2 <- freqlist(txt2, as_text = TRUE)
(scores <- assoc_scores(flist1, flist2, min_freq = 0))
#> Association scores (types in list: 46)
#>        type   a    PMI G_signed|   b   c    d dir exp_a DP_rows RR_rows
#>  1      old 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  2     same 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  3      the 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  4     year 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  5        a 1.0 -1.121   -1.535|30.0 3.0 23.0  -1 2.175  -0.083   0.280
#>  6    after 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#>  7     bowl 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#>  8    fears 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#>  9     fish 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 10    found 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 11   ground 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 12     have 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 13     here 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 14       in 1.0 -0.121   -0.016|30.0 1.0 25.0  -1 1.088  -0.006   0.839
#> 15     just 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 16     lost 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 17     over 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 18  running 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 19    souls 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 20 swimming 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> ...
#> <number of extra columns to the right: 6>
#> 
.old_wd <- setwd(tempdir())
write_assoc(scores, "example_scores.tab")
(scores2 <- read_assoc("example_scores.tab"))
#> Association scores (types in list: 46)
#>        type   a    PMI G_signed|   b   c    d dir exp_a DP_rows RR_rows
#>  1      old 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  2     same 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  3      the 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  4     year 2.5  0.620    1.192|29.5 0.5 26.5   1 1.627   0.060   4.219
#>  5        a 1.0 -1.121   -1.535|30.0 3.0 23.0  -1 2.175  -0.083   0.280
#>  6    after 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#>  7     bowl 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#>  8    fears 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#>  9     fish 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 10    found 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 11   ground 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 12     have 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 13     here 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 14       in 1.0 -0.121   -0.016|30.0 1.0 25.0  -1 1.088  -0.006   0.839
#> 15     just 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 16     lost 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 17     over 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 18  running 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 19    souls 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> 20 swimming 1.5  0.468    0.380|30.5 0.5 26.5   1 1.085   0.028   2.531
#> ...
#> <number of extra columns to the right: 6>
#> 
setwd(.old_wd)