Reputation: 11
I'm using quanteda, an R package for managing and analyzing text. I am running into trouble with one of its core functons: "dfm" which is used for constructing a document frequency matrix.
Running the function
# Install packages
packages <- function(x){
x <- as.character(match.call()[[2]])
if (!require(x,character.only=TRUE)){
install.packages(pkgs=x,repos="http://cran.r-project.org")
require(x,character.only=TRUE)
}
}
packages("XML")
packages("textcat")
packages("tm")
packages("RTextTools")
packages("stringi")
packages("proxy")
packages("cluster")
packages("topicmodels")
packages("dplyr")
packages("plyr")
packages("stringr")
packages("quanteda")
packages("ggplot2")
packages("RWeka")
# Build textfile using 2nd field text for analysis
txt <- textfile("myfile.csv",textField = 2)
# Build object of class corpus from txt
MyCorpus <- corpus(txt)
# Construct a document-frequency matrix
myDfm <- dfm(MyCorpus)
Code and error returned
Creating a dfm from a corpus ...
... indexing 55 documents
... tokenizing texts, found 1,730 total tokens
... cleaning the tokens, 17 removed entirely
... summing tokens by document
... indexing 710 feature types
... building sparse matrix
Error in validObject(.Object) :
invalid class “dfmSparse” object: superclass "dCsparseMatrix" not defined in the environment of the object's class
As you can see, the function is running but then gets stuck just after "building sparse matrix". I do not understand this error or how to approach tackling it. Any advice?
Upvotes: 0
Views: 442