Learn R Programming

polmineR (version 0.7.11)

kwic-class: kwic (S4 class)

Description

S4 class for organizing information for kwic/concordance output. A set of standard generics (show, as.character, as.data.frame, length, sample, subset) as well as indexing is implemented to process kwic class objects (see 'Usage'). See section 'Details' for the enrich, view and knit_print methods.

Usage

# S4 method for kwic
show(object)

# S4 method for kwic knit_print(x, pagelength = getOption("polmineR.pagelength"), options = knitr::opts_chunk, ...)

# S4 method for kwic as.character(x, fmt = "%s")

# S4 method for kwic,ANY,ANY,ANY [(x, i)

# S4 method for kwic subset(x, ...)

# S4 method for kwic as.data.frame(x)

# S4 method for kwic length(x)

# S4 method for kwic sample(x, size)

# S4 method for kwic enrich(.Object, s_attributes = NULL, table = FALSE, ...)

# S4 method for kwic view(.Object)

Arguments

object

A kwic class object.

x

A kwic class object.

pagelength

The number of kwic lines displayed per page in the datatables htmlwidget that is returned.

options

Chunk options.

...

Used for backwards compatibility.

fmt

A format string passed into sprintf to format the node of a KWIC display.

i

Single integer value, the kwic line for which the fulltext shall be inspected.

size

An integer, subset size for sampling.

.Object

A kwic class object.

s_attributes

Character vector of s-attributes with metainformation.

table

Logical, whether to turn cpos data.table into data.frame for output.

Slots

metadata

A character vector with s-attributes of the metadata that are to be displayed.

p_attribute

The p-attribute for which the context has been generated.

left

An integer value, words to the left of the query match.

right

An integer value, words to the right of the query match.

corpus

Length-one character vector, the CWB corpus.

cpos

A data.table with the columns "hit_no", "cpos", "position", "word_id", "word" and "direction".

table

A data.frame, a table with columns "left", "node", "right", and metadata, if the object has been enriched.

encoding

A length-one character vector with the encoding of the corpus.

labels

A character vector with labels.

categories

A character vector.

Details

The knit_print will be called by knitr when processing code chunks in Rmarkdown documents to include a htmlwidget into the resulting html document. It may be necessary to explicitly state "render=knit_print" in the chunk options.

The subset-method will apply subset to the table in the slot table, for filtering query results based on metadata (i.e. s-attributes) that need to be present.

The enrich method is used to generate the actual output for the kwic method. If param table is TRUE, corpus positions will be turned into a data.frame with the concordance lines. If param s_attributes is a character vector with s-attributes, the respective s-attributes will be added as columns to the table with concordance lines.

See Also

The constructor for generating kwic objects is the kwic method.

Examples

Run this code
# NOT RUN {
use("polmineR")
K <- kwic("GERMAPARLMINI", "Integration")
length(K)
K_min <- K[1]
K_min <- K[1:5]
oil <- kwic("REUTERS", query = "oil")
as.character(oil)
# }

Run the code above in your browser using DataLab