Introduction to Natural Language Processing in R
Learn to clean and tokenize text in R, build TF-IDF matrices, and apply classification, LDA topic models, sentiment analysis and word embeddings.
The lessons build an R workflow for working with written text. You match patterns with regular expressions, split text into word and sentence tokens, and strip stop words and word endings. Documents are then turned into bag-of-words and TF-IDF matrices and compared by cosine similarity. Those pieces feed classification models, LDA topic models, sentiment scoring and word2vec embeddings, with short looks at BERT, part-of-speech tagging and named entity recognition.
What You Will Achieve
- Write regular expressions and tidytext code that tokenize, clean and stem raw text
- Turn a set of documents into a weighted matrix and measure how alike two texts are
- Fit a text classifier and judge its errors, then assign documents to LDA topics and test the model’s perplexity
- Score sentiment and emotion in text with lexicons and train word2vec embeddings in h2o
Program Overview
Regular Expressions, Tokenization and Text Cleaning
Pattern matching and tokenization prepare raw text for every later method in the course.
- Regular expression syntax with grep and related functions
- Word and sentence tokenization with tidytext
- Stop word removal and stemming
Corpus, Bag-of-Words and TF-IDF
Text is stored as a corpus and recast as numeric matrices so documents can be weighed and compared.
- Creating and exploring an R corpus
- Bag-of-words and sparse matrices
- TF-IDF by hand and in code
- Cosine similarity between texts
Classification, Topic Modeling and Sentiment Analysis
Prepared text feeds classification and topic models, then sentiment scores and word embeddings, with a short tour of further NLP techniques and a review of the methods.
- Removing sparse terms, classification models and confusion matrices
- LDA topics, document assignment and perplexity
- Sentiment lexicons, emotion and word2vec with h2o
- BERT, part-of-speech tagging and named entity recognition
Certificate Awarded (Paid)
Job Outlook
These methods apply wherever an analyst or data scientist working in R needs to clean, classify, group or score written text.
Good for: R users who want a hands-on tour of the standard text analysis methods, with short practice exercises for each one.
Keep in mind: Despite its intermediate label it introduces NLP and machine learning concepts from scratch, and BERT, part-of-speech tagging and named entity recognition get only a brief look.
Bottom line: It works through almost fifteen text analysis techniques in R, and spends most of its time on bag-of-words, TF-IDF and topic models.
Frequently Asked Questions
Does the course teach BERT?
Only briefly. BERT appears near the end alongside part-of-speech tagging and named entity recognition, while most of the course works with bag-of-words, TF-IDF, topic models and other foundational methods.
Which R tools handle the text and the embeddings?
The course works with tidytext functions and lexicons for tokenizing text and scoring sentiment, and with h2o for training word2vec embeddings. Text also moves between tibbles, corpora and document-term matrices along the way.
How are topic models checked in the course?
Topic models are built with LDA, each document is assigned to a topic, and the course and the lessons then test the model's perplexity and review the LDA results.
Please log in to report a problem with this page.


There are no reviews yet.