Skip to contents

This function reads concordance-based data frames that are written to file with the function write_conc().

Usage

read_conc(
  file,
  sep = "\t",
  file_encoding = "UTF-8",
  stringsAsFactors = FALSE,
  ...
)

Arguments

file

Name of the input file.

sep

Field separator used in the input file.

file_encoding

Encoding of the input file.

stringsAsFactors

Logical. Whether character data should automatically be converted to factors. It applies to all columns except for "source", "left", "match" and "right", which are never converted.

...

Additional arguments, not implemented.

Value

Object of class conc.

See also

import_conc() for reading files not generated with write_conc().

Other reading functions: read_assoc(), read_fnames(), read_freqlist(), read_tokens(), read_txt(), read_types()

Examples

(d <- conc('A very small corpus.', '\\w+', as_text = TRUE))
#> Concordance-based data frame (number of observations: 4)
#> idx                                           left|match |right             
#>   1                                               |  A   |very small corpus.
#>   2                                              A| very |small corpus.     
#>   3                                         A very|small |corpus.           
#>   4                                   A very small|corpus|.                 
#> 
#> This data frame has 6 columns:
#>    column
#> 1 glob_id
#> 2      id
#> 3  source
#> 4    left
#> 5   match
#> 6   right
.old_wd <- setwd(tempdir())
write_conc(d, "example_data.tab")
(d2 <- read_conc("example_data.tab"))
#> Concordance-based data frame (number of observations: 4)
#> idx                                           left|match |right             
#>   1                                               |  A   |very small corpus.
#>   2                                              A| very |small corpus.     
#>   3                                         A very|small |corpus.           
#>   4                                   A very small|corpus|.                 
#> 
#> This data frame has 6 columns:
#>    column
#> 1 glob_id
#> 2      id
#> 3  source
#> 4    left
#> 5   match
#> 6   right
setwd(.old_wd)