AI Text Generation in R: Prompt, Skill, and Context Engineering - A Short Course
An 8-Hour Livestream Seminar Taught by Hudson Golino, Ph.D.
Read reviews of this courseThis seminar is part of the AI-Enabled Data Analytics Certification, a series of 4 expert-led courses designed to build practical AI skills for research and data analysis. Contact us to learn how to complete your certification and access special pricing.
Have you ever wondered how to use AI to automatically generate text data, such as survey or questionnaire items, for your research? Would you like more control over what ChatGPT, Claude, and other large language models (LLMs) produce? Have you noticed that the same model can produce excellent results in one setting and poor results in another, and wondered how to control the information it receives to improve reliability and reproducibility? If so, this course is for you.
This intensive two-day workshop provides a comprehensive introduction to AI text generation in the R programming environment, organized around three complementary layers of control. Prompt engineering is about writing a single instruction well. Skill engineering is about packaging instructions, examples, and output formats into reusable, testable components (implemented as R functions) designed to produce consistent results across tasks and projects. Context engineering is about designing everything the model sees when it generates a response: system messages, expert personas, worked examples, source documents such as research papers, and the outputs of earlier steps in a pipeline.
Whether you are new to working with LLMs or are an experienced data scientist, this course will give you the knowledge and hands-on practice needed to move beyond trial-and-error prompting and to build LLM workflows whose behavior you can guide, inspect, and refine for reuse in research applications such as item generation, document-grounded text generation, and synthetic text data for analysis.
Starting February 17, this seminar will be presented as an 8-hour synchronous, livestream workshop via Zoom. Each day will feature two lecture sessions with hands-on exercises, separated by a 30-minute break. Live attendance is recommended for the best experience. If you can’t join in real time, recordings will be available within 24 hours and accessible for four weeks after the seminar.
Closed captioning is available for all live and recorded sessions. Captions can be translated to a variety of languages, including Spanish, Korean, and Italian. For more information, click here.
ECTS Equivalent Points: 1
More Details About the Course Content
In this seminar, you will work with OpenAI models (GPT-5.2 and the open-weight GPT-OSS-120b and GPT-OSS-20b), Anthropic’s Claude models, and other open models such as Llama-3.3, Llama-4, and Qwen-3, all accessed from R through APIs (OpenAI, Anthropic, and GroqCloud).
By the end of this course, you will be able to:
-
- Set up and configure LLM APIs (OpenAI, Anthropic, and Groq) within the R environment.
- Apply core prompt engineering techniques, including role prompting, few-shot learning, chain-of-thought reasoning, and prompt chaining.
- Engineer the context of each request (system messages, expert personas, examples, and source documents) to control the quality and consistency of model outputs.
- Build reusable skills: R functions that package instructions, examples, and output formats for tasks such as generating complete survey batteries.
- Ground text generation in research papers (PDFs) by extracting key concepts and supplying them as context for theory-informed item development.
- Chain multiple LLM calls into automated pipelines for large-scale text generation and analysis, passing the output of each step as context for the next.
- Minimize hallucinations through evidence-based grounding techniques.
For a related course on building AI research agents and automated workflows in R, see LLM Agents for Research Using R.
Computing
This is a hands-on course with instructor-led software demonstrations and guided exercises. The exercises use the R programming language, so you should use a computer with a recent version of R (version 4.1.3 or later) and RStudio (version 2022.02.1+461 or later). Software requirements and installation instructions will be provided before the course.
To follow along with the course exercises, you should be comfortable using R, including opening data files, running scripts, and performing basic data manipulation and analysis.
The exercises will also use UV, a fast Python package manager, and API keys from LLM cloud providers. All necessary instructions will be provided before the seminar begins.
If you’d like to take this course but are concerned that you don’t know enough R, there are excellent online resources for learning the basics. Here are our recommendations.
Who Should Register?
This course is designed for anyone interested in prompt, skill, and context engineering for AI text generation who has a good working knowledge of R, gained through courses such as Introduction to R for Data Analysis, R for SAS Users, R for SPSS Users with LLM Applications, or R for Stata Users.
Outline
Day 1: Foundations of LLMs and prompt engineering in R
Introduction to LLMs and API setup (GPT-5.2, the open-weight GPT-OSS-120b and GPT-OSS-20b, Anthropic’s Claude models, and other open models such as Llama-3.3, Llama-4, and Qwen-3)
-
- Understanding the concept of language models
- Comparing the capabilities and limitations of different models
- Differentiating API systems with GPUs and LPUs
- Exploring real-world applications
Setting up the R environment for LLMs
-
- Installing necessary libraries and packages
- Authenticating with the OpenAI API
- Authenticating with the Anthropic API
- Authenticating with the GroqCloud API
- Obtaining API keys
Basic text generation
-
- Creating your first LLM request in R via OpenAI, Anthropic, and GroqCloud APIs
- Generating text for simple prompts in R
- Anatomy of effective prompts for research applications
- From prompts to context: everything the model sees in a request (system message, user message, examples, and documents)
- Parameter tuning (temperature, max_tokens) for optimal outputs
- Handling responses and formatting output in R
Day 2: Context and skill engineering with OpenAI, Anthropic, and open models
Role prompting: engineering the system context
-
- System vs. user messages for behavioral control
- Creating expert personas (psychometrician, market researcher, educational psychologist)
- Comparative analysis of role-specific outputs
- Generating Big Five personality items using expert personas
Few-shot learning and building reusable skills
-
- Few-shot prompting with domain-specific examples
- Packaging instructions, examples, and output formats into reusable item-generation skills (R functions)
- Creating complete survey batteries with CSV output
- Quality assessment and validation techniques
- Job satisfaction scale development across multiple domains
Chain-of-thought reasoning
-
- Step-by-step problem solving for complex research questions
- Methodological decision-making with LLM assistance
- Using LLMs to support statistical analysis planning and assumption checks
Context engineering with documents: grounding, PDF integration, and prompt chaining
-
- Minimizing hallucinations through document grounding
- PDF text extraction and preprocessing techniques
- Concept extraction from research literature
- Prompt chaining: passing the output of each step (answers, concepts, items) as context for the next
- Generating theory-informed items from academic papers
Generating synthetic text data for topic modeling in R
-
- Generating text for topic modeling using OpenAI and open models
Reviews of AI Text Generation in R: Prompt, Skill, and Context Engineering
“Dr. Golino’s course is an engaging combination of background, conceptual, and applied knowledge. It helped me move from being interested and curious to developing a solid baseline understanding of the topic and its issues and then applying that knowledge to my own work.”
Maggi Mackintosh, U.S. Department of Veterans Affairs
Seminar Information
Wednesday, February 17 –
Thursday, February 18, 2027
Daily Schedule: All sessions are held live via Zoom. All times are ET (New York time).
10:30am-12:30pm (convert to your local time)
1:00pm-3:00pm
Payment Information
The fee of $695 USD includes all course materials.
PayPal and all major credit cards are accepted.
Need funding from your employer or institution? Use our funding request template.
Our Tax ID number is 26-4576270.

Back to Public Seminars