Learn R Programming

text2vec is an R package which provides an efficient framework with a concise API for text analysis and natural language processing (NLP).

Goals which we aimed to achieve as a result of development of text2vec:

  • Concise - expose as few functions as possible
  • Consistent - expose unified interfaces, no need to explore new interface for each task
  • Flexible - allow to easily solve complex tasks
  • Fast - maximize efficiency per single thread, transparently scale to multiple threads on multicore machines
  • Memory efficient - use streams and iterators, not keep data in RAM if possible

See API section for details.

Performance

This package is efficient because it is carefully written in C++, which also means that text2vec is memory friendly. Some parts are fully parallelized using OpenMP.

Other emrassingly parallel tasks (such as vectorization) can use any fork-based parallel backend on UNIX-like machines. They can achieve near-linear scalability with the number of available cores.

Finally, a streaming API means that users do not have to load all the data into RAM.

Contributing

The package has issue tracker on GitHub where I'm filing feature requests and notes for future work. Any ideas are appreciated.

Contributors are welcome. You can help by:

License

GPL (>= 2)

Copy Link

Version

Install

install.packages('text2vec')

Monthly Downloads

68,024

Version

0.6.6

License

GPL (>= 2) | file LICENSE

Maintainer

Dmitriy Selivanov

Last Published

December 1st, 2025

Functions in text2vec (0.6.6)

jsPCA_robust

(numerically robust) Dimension reduction via Jensen-Shannon Divergence & Principal Components
print.text2vec_vocabulary

Printing Vocabulary
vectorizers

Vocabulary and hash vectorizers
tokenizers

Simple tokenization functions for string splitting
split_into

Split a vector for parallel processing
text2vec

text2vec
prune_vocabulary

Prune vocabulary
reexports

Objects exported from other packages
similarities

Pairwise Similarity Matrix Computation
perplexity

Perplexity of a topic model
prepare_analogy_questions

Prepares list of analogy questions
Collocations

Collocations model.
BNS

BNS
LatentSemanticAnalysis

Latent Semantic Analysis model
create_tcm

Term-co-occurence matrix construction
create_vocabulary

Creates a vocabulary of unique terms
normalize

Matrix normalization
movie_review

IMDB movie reviews
RelaxedWordMoversDistance

Creates Relaxed Word Movers Distance (RWMD) model
TfIdf

TfIdf
GloVe

re-export rsparse::GloVe
itoken

Iterators (and parallel iterators) over input objects
as.lda_c

Converts document-term matrix sparse matrix to 'lda_c' format
combine_vocabularies

Combines multiple vocabularies into one
create_dtm

Document-term matrix construction
LatentDirichletAllocation

Creates Latent Dirichlet Allocation model.
check_analogy_accuracy

Checks accuracy of word embeddings on the analogy task
coherence

Coherence metrics for topic models
distances

Pairwise Distance Matrix Computation
ifiles

Creates iterator over text files from the disk