I am trying to convert a dgcMatrix to datatable in R using following piece of code:
feats <- as.data.table(as.matrix(dtm_text))
But it throws an error like this:
Error in nchar(collabs) : invalid multibyte string, element 149
Does anyone have the reason for this error or another way to achieve the same??
A small part of the code before the problem line
bow <- itoken(trte_data$Description, preprocessor = tolower ,tokenizer =
word_tokenizer, ids = trte_data$User_ID)
bow_vocab <- create_vocabulary(bow)
pruned_bow <- prune_vocabulary(bow_vocab, term_count_min = 100)
vovec <- vocab_vectorizer(pruned_bow)
dtm_text <- create_dtm(bow, vovec)