This function coerces a data frame to an object of the class conc.
as_conc(x, left = NA, match = NA, right = NA, keep_original = FALSE, ...)Object of class conc, a kind of data frame with as its rows
the matches and with the following columns:
glob_id: Number indicating the position of the match in the
overall list of matches.
id: Number indicating the position of the match in the list of matches
for one specific query.
source: Either the filename of the file in which the match was found
(in case of the setting as_text = FALSE), or the string '-'
(in case of the setting as_text = TRUE).
left: The left-hand side co-text of each match.
match: The actual match.
right: The right-hand side co-text of each match.
It also has additional attributes and methods such as:
base as_data_frame() and print() methods, as well as
a print_kwic() function,
an explore() method.
An object of class conc can be merged with another by means of merge_conc().
It can be written to file with write_conc() and then
read with read_conc(). It is also possible to import concordances created
by means other than write_conc() with import_conc().
A data frame.
The name of the column in x that contains the left co-text
of the concordance. Is is.na(left), then this column is assumed
to have the name "left".
The name of the column in x that contains the match
of the concordance. Is is.na(match), then this column is assumed
to have the name "match".
The name of the column in x that contains the right co-text
of the concordance. Is is.na(right), then this column is assumed
to have the name "right".
Logical. If the values of
left, match or right are not NA, should
the original names of those columns be kept in the conc object.
Additional arguments.
(conc_data <- conc('A very small corpus.', '\\w+', as_text = TRUE))
df <- as.data.frame(conc_data)
as_conc(df)
Run the code above in your browser using DataLab