bundle: Bundle Class

bundle-classR Documentation

Bundle Class

Description

A bundle is used to combine several objects (partition, context, features, cooccurrences objects) into one S4 class object. Typically, a class inheriting from the bundle superclass will be used. When working with a context_bundle, a features_bundle, a cooccurrences_bundle, or a context_bundle, a similar set of standard methods is available to perform transformations.

Usage

## S4 replacement method for signature 'bundle'
name(x) <- value

## S4 method for signature 'bundle'
length(x)

## S4 method for signature 'bundle'
names(x)

## S4 replacement method for signature 'bundle,vector'
names(x) <- value

## S4 method for signature 'bundle'
unique(x)

## S4 method for signature 'bundle,bundle'
e1 + e2

## S4 method for signature 'bundle,textstat'
e1 + e2

## S4 method for signature 'bundle'
x[[i]]

## S4 method for signature 'bundle,ANY,ANY,ANY'
x[i]

## S4 replacement method for signature 'bundle'
x[[i]] <- value

## S4 method for signature 'bundle'
x$name

## S4 replacement method for signature 'bundle'
x$name <- value

## S4 method for signature 'bundle'
sample(x, size)

## S4 method for signature 'list'
as.bundle(object, ...)

## S4 method for signature 'textstat'
as.bundle(object)

## S3 method for class 'bundle'
as.data.table(x, keep.rownames, col, ...)

## S4 method for signature 'bundle'
as.matrix(x, col)

## S4 method for signature 'bundle'
subset(x, ...)

## S4 method for signature 'bundle'
as.list(x)

## S3 method for class 'bundle'
as.list(x, ...)

## S4 method for signature 'bundle'
get_corpus(x)

Arguments

x

a bundle object

value

character string with a name to be assigned

e1

object 1

e2

object 2

i

integer or character values for indexing a bundle object.

name

The name of an object in the bundle object.

size

number of items to choose to generate a sample

object

A bundle object.

...

Further parameters

keep.rownames

Required argument to safeguard consistency with S3 method definition in the data.table package. Unused in this context.

col

columns of the data.table to use to generate an object.

Slots

corpus

The CWB corpus the xobjects in the bundle are based on, a length 1 character vector.

objects

An object of class list.

p_attribute

Object of class character.

encoding

The encoding of the corpus.

Author(s)

Andreas Blaette

Examples

party_bundle <- partition_bundle("GERMAPARLMINI", s_attribute = "party")

length(party_bundle)
names(party_bundle)
get_corpus(party_bundle)

party_bundle <- enrich(party_bundle, p_attribute = "word")
summary(party_bundle)

# Indexing bundle objects
reu <- corpus("REUTERS") %>% split(s_attribute = "id")
reu[1:3]
reu[-1]
reu[-(1:10)]
reu["127"]
reu[c("127", "273")]

p <- partition("GERMAPARLMINI", date = "2009-11-11")
pb <- partition_bundle(p, s_attribute = "party")
names(pb)
pb[["NA"]] <- NULL
names(pb)
pb <- partition_bundle("GERMAPARLMINI", s_attribute = "party")
pb$SPD # access partition names "SPD" in partition_bundle pb
pb <- partition_bundle("GERMAPARLMINI", s_attribute = "party")
pb$"NA" <- NULL # quotation needed if name is "NA"
use(pkg = "RcppCWB", corpus = "REUTERS")

pb <- partition_bundle("REUTERS", s_attribute = "id")
coocs <- cooccurrences(pb, query = "oil", cqp = FALSE)
dt <- as.data.table(coocs, col = "ll")
m <- as.matrix(dt[, 2:ncol(dt)], rownames = dt[["token"]])

polmineR documentation built on Aug. 26, 2022, 5:15 p.m.