Using AI
How to Use AI to Learn Statistics and R Coding, Without Letting It Learn for You
Artificial intelligence has transformed how we learn. In my opinion, AI can be extremely beneficial for students and learners in general. You can learn an entire field of science with AI. It is truly a remarkable tool. As with any powerful tool, it can greatly enhance our lives—or, in some cases, impoverish them. If I had to summarise the main pros and cons, I would say the big pro is that it is a tireless, knowledgeable tutor that lets you dig deeper and deeper into topics. The main con is letting AI think for you, without you having learned and processed the information.
For students of statistics and R programming, AI tools like ChatGPT, Copilot, Claude, or Gemini can serve as tutors, feedback partners, and idea generators. But like any good tutor, AI works best with you, not for you.
Used thoughtfully, AI can help you understand complex ideas, write cleaner R code, and reinforce conceptual understanding. Used carelessly, it can short-circuit your learning, leaving you with copied answers and no deeper grasp of the “why.”
Let’s look at how to make AI a learning ally, not a crutch—with examples, prompting tips, and common pitfalls to avoid.
1. The Role of AI in Learning — Tutor, Not Substitute
AI should play three main roles in your learning:
- Explainer: clarifying tricky concepts in different ways until one clicks.
- Coach: giving hints, feedback, and structured learning plans.
- Example generator: showing you how abstract ideas work in realistic contexts.
AI should not:
- Write full assignments for you.
- Generate entire code chunks you don’t understand.
- Provide explanations for you to memorise without testing your comprehension.
Think of AI as your study buddy who knows a lot, but expects you to think critically.
2. Learning Statistics with AI: Ask to Understand, Not to Memorise
We all have different ways of learning, but one way I find generally useful is to work through examples, build an intuition, then work through a formalisation (e.g., equations), linking the formalisation to simple numerical examples. From there, build more complex examples and do some practice, like maths or coding exercises.
Let’s take a basic example: learning the concept of variance—not only what it means in words, but also in equation form and in programming form.
If you ask:
“Explain the concept of variance.”
You’ll get a decent first textbook-style explanation. What’s crucial afterwards is to go over, with your AI tutor, every detail that isn’t clear.
To learn with AI, you should prompt for depth, perspective, and relevance (and have a great deal of perseverance).
Be specific about what you know
If the first explanation was too complex, you can make your prompt more specific. For instance, if you already understand the concept of the mean, you could try:
“Explain variance in simple terms, like you would to someone who understands the concept of mean and median but struggles with variance.”
Sometimes, to understand a higher-level concept, you need to take a step back and build up to it.
For example, if you don’t yet fully understand the equation for the mean, you could ask:
“I would like to understand the concept of variance, but I struggle with the equation for the mean. Could you start by explaining the terms in the equation for the mean, and from there, explain the concept of variance and how to interpret its equations? I’m really into football — could you please use examples from football?”
Go over the details of what exactly you don’t understand
“I understand the general idea of variance, but I’m puzzled about why we square the differences when calculating variance. What would happen if we didn’t?”
This helps you learn why variance works mathematically, not just how it’s computed.
Personalised context
Personalisation is one of the great advantages of AI tutoring. Ask it to explain concepts with examples that resonate with you.
“Give an example of variance that relates to daily life, such as the time it takes me to get to work each day.” “Give an example of variance that relates to cycling.” “Give an example of variance that relates to gender equality in pay.”
Now AI connects statistics to you which makes the learning stick.
Exercises
Practice is fundamental to learning, and you should ask AI to write exercises following your progression.
“Give me a short quiz with three questions to test my understanding of variance.”
This transforms AI into an interactive tutor, not a passive dictionary.
3. Learning R Coding with AI
AI can generate R scripts for you, but that’s not the same as learning to code.
Here are best practices for using AI as a coding tutor:
Good Prompts
- “Here’s my R code that doesn’t work — can you help me debug it, but only give hints first?”
- “Can you explain step by step what each line in this R function does?”
- “Show me two different ways to plot this dataset: one with
ggplot2, one with base R.” - “I wrote code to compute variance manually; can you check if it’s efficient or accurate?”
These help you engage with the process, you’re asking AI to teach through explanation, not replace your effort.
Poor Prompts
- “Write a function that calculates variance in R.”
- “Give me R code to clean and visualise this dataset.”
You’ll get code, but not insight. You’ll know what works, not why it works.
4. Prompting Guidelines for Deep Learning
When you use AI for self-learning, your prompts determine the quality of your understanding. Use these prompting patterns to learn more effectively:
| Goal | Example Prompt | Mechanisms |
|---|---|---|
| Understand a concept | “Explain standard deviation using an analogy involving cooking.” | Makes abstract ideas concrete. |
| Compare concepts | “What’s the difference between variance and standard deviation? Explain like I’m a high school student.” | Builds relational understanding. |
| Apply to your context | “Show an example of regression that could apply to environmental data.” | Encourages transfer of knowledge. |
| Debug code | “My R plot isn’t showing. Can you point out possible mistakes without rewriting my code?” | Keeps you problem-solving. |
| Build independence | “Ask me 3 conceptual questions about sampling distributions to test my understanding.” | Promotes self-assessment. |
5. Learning Workflow with AI and R
A productive way to integrate AI into your R learning routine might look like this:
- Read a concept (from a book, course, or article).
- Try coding it yourself — even if imperfectly.
- Ask AI to review or explain your code, focusing on reasoning.
- Ask for variations or extensions (“What if I use a non-numeric variable?”).
- Summarise the concept in your own words, and ask AI to check your summary for accuracy.
This iterative cycle ensures retention, not regurgitation.