as.DocumentTermMatrix: as.TermDocumentMatrix / as.DocumentTermMatrix

Description Usage Arguments Details Value Author(s) Examples

Description

Method for type conversion, to generate the classes "TermDocumentMatrix" or "DocumentTermMatrix" contained in the "tm" package. The classes inherit from the "simple_triplet_matrix"-class defined in the "slam"-package. A "DocumentTermMatrix" is required as input by the "topicmodels" package, for instance.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
as.TermDocumentMatrix(x, ...)

## S4 method for signature 'character'
as.TermDocumentMatrix(x, pAttribute, sAttribute,
  verbose = TRUE)

## S4 method for signature 'character'
as.DocumentTermMatrix(x, pAttribute, sAttribute,
  verbose = TRUE)

## S4 method for signature 'bundle'
as.TermDocumentMatrix(x, col, pAttribute = NULL,
  verbose = TRUE)

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

## S4 method for signature 'partitionBundle'
as.TermDocumentMatrix(x, pAttribute = NULL,
  col = NULL, verbose = TRUE)

## S4 method for signature 'partitionBundle'
as.DocumentTermMatrix(x, pAttribute = NULL,
  col = NULL, verbose = TRUE)

Arguments

x

some object

...

to make the check happy

pAttribute

the p-attribute

sAttribute

the s-attribute

verbose

bla

col

the column to use of assembling the matrix

Details

The type conversion-method can be applied on object of the class "bundle", or classes inheriting from the "bundle" class. If counts or some other measure is present in the "stat" slots of the objects in the bundle, then the values in the column indicated by "col" will be turned into the values of the sparse matrix that is generated. A special case is the generation of the sparse matrix based on a "partitionBundle" that does not yet include counts. In this case, a "pAttribute" needs to be provided, then counting will be performed, too.

Value

a TermDocumentMatrix

Author(s)

Andreas Blaette

me

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
use("polmineR.sampleCorpus")
 
# do-it-yourself 
p <- partition("PLPRBTTXT", text_date=".*", regex=TRUE)
pB <- partitionBundle(p, sAttribute="text_date")
pB <- enrich(pB, pAttribute="word")
tdm <- as.TermDocumentMatrix(pB, col="count")
   
 # leave the counting to the as.TermDocumentMatrix-method
pB2 <- partitionBundle(p, sAttribute="text_date")
tdm <- as.TermDocumentMatrix(pB2, pAttribute="word")
   
# diretissima
tdm <- as.TermDocumentMatrix("PLPRBTTXT", pAttribute="word", sAttribute="text_date")

## End(Not run)

nrauscher/corpus documentation built on May 23, 2019, 9:34 p.m.