Skip to content
Back to skills

Text2vec

ASecurity

R text2vec package for text vectorization. Use for word embeddings, GloVe, and efficient text processing.

  • 5 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 4, 2026
ai-agents

Security analysis

A100/100

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill text2vec --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Text2vec?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Text2vec
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-text2vec/badge)](https://www.skillsdirectory.com/skills/leolin990405-text2vec)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: text2vec
description: R text2vec package for text vectorization. Use for word embeddings, GloVe, and efficient text processing.
---

# text2vec Package

Fast text vectorization and embeddings.

## Tokenization

```r
library(text2vec)

# Iterator
it <- itoken(texts,
  preprocessor = tolower,
  tokenizer = word_tokenizer
)

# From files
it <- ifiles("*.txt") %>%
  itoken(tokenizer = word_tokenizer)
```

## Vocabulary

```r
# Create vocabulary
vocab <- create_vocabulary(it)

# Prune
vocab <- prune_vocabulary(vocab,
  term_count_min = 5,
  doc_proportion_max = 0.5
)

# Vectorizer
vectorizer <- vocab_vectorizer(vocab)
```

## Document-Term Matrix

```r
# Create DTM
dtm <- create_dtm(it, vectorizer)

# TF-IDF
tfidf <- TfIdf$new()
dtm_tfidf <- fit_transform(dtm, tfidf)
```

## Word Embeddings (GloVe)

```r
# Co-occurrence matrix
tcm <- create_tcm(it, vectorizer, skip_grams_window = 5)

# Train GloVe
glove <- GloVe$new(rank = 100, x_max = 10)
word_vectors <- glove$fit_transform(tcm, n_iter = 20)

# Get word vector
word_vectors["king", ]

# Word analogies
king <- word_vectors["king", ]
man <- word_vectors["man", ]
woman <- word_vectors["woman", ]
queen_vec <- king - man + woman
```

## Topic Modeling (LDA)

```r
lda <- LDA$new(n_topics = 10)
doc_topics <- lda$fit_transform(dtm, n_iter = 100)

# Top words per topic
lda$get_top_words(n = 10)
```

## Similarity

```r
# Cosine similarity
sim <- sim2(dtm[1:10, ], dtm, method = "cosine")

# Jaccard
sim <- sim2(dtm, method = "jaccard")
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.