Learn R Programming

phm (version 2.1.2)

as.matrix.phraseDoc: Convert a phraseDoc Object to a Matrix

Description

Convert a phraseDoc Object to a Matrix

Usage

# S3 method for phraseDoc
as.matrix(x, ids = TRUE, sparse = FALSE, ...)

Value

A matrix with phrases as rows, texts as columns, and elements containing the number of times the phrase occurs in the text

Arguments

x

A phraseDoc object.

ids

A logical value with TRUE (default) to use ids (if available), FALSE to use indices

sparse

A logical value indicates whether a sparse matrix should be returned (default FALSE)

...

Additional arguments

Examples

Run this code
tst=c("This is a test text",
      "This is a test text 2",
      "This is another test text",
      "This is another test text 2",
      "This girl will test text that man",
      "This boy will test text that man")
pd=phraseDoc(tst)
as.matrix(pd)

Run the code above in your browser using DataLab