Key Points
Introducing LLMs as a Tool to Learn R
- Choosing which and when to use Generative AI tools require thoughtful goal-setting
- R and RStudio provide a reasonable entry point with a large and welcoming community
- The Gapminder dataset contains global metrics for data analysis
Writing Effective AI Prompts
- Providing context such as programming language, dataset, and goals can lead to better AI responses
- Follow-up questions help personalize learning and deepen understanding
- Modify code by starting with code, asking for changes, reviewing the code, and testing the code
Analysing a Real Program
- “Reverse-engineering” existing code and inserting
printstatements can help you develop your understanding of how code works. - Develop your own expertise by comparing a chatbot’s explanations to your own understanding and finding practical ways to test the explanations.
Learning About Programming Concepts
- Being specific about what you know already and what exactly you need to be explained will increase your chances of getting a helpful response.
- Avoid the illusion of competence by putting your knowledge and skills into practice instead of passively consuming responses from a chatbot.
Modifying Code
- Following established principles to organise and document your programs makes them easier to maintain.
- When instructing a chatbot to change a program, provide relevant context and be precise about what you want to change and why.
- Be reflective about how you use a chatbot and test your understanding of the code it generates to keep building your own expertise.
- Approaches that work well for novices working with small programs may not scale well to larger software and bigger projects.
Validating What We Have Made
- Code that runs without errors and produces plausible-looking output can still contain logical errors.
- It’s important to check AI-generated code and in order to sport logical errors.
- Work out the expected answer by hand on a small dataset before running the code, then compare.
- Print statements let you inspect intermediate values and see what the code is actually doing.
- Focus the most scrutiny on the calculations behind the results you will report, and less scrutiny on routine boilerplate such as plotting code.
- Asking a chatbot to review code can be a useful extra check, but a review that finds nothing wrong is not proof of correctness, and any suggested fixes need to be re-tested.
- It’s not only the code itself that needs validating. Check that suggested packages exist, are the official ones, and are not lookalikes of popular names.