Getting Started with GitHub Copilot
- A GitHub account is required to use GitHub Copilot
- Students can get free GitHub Copilot access through the GitHub Student Developer Pack
- GitHub Copilot integrates directly into RStudio as an autocompletion tool
- Test Copilot by writing descriptive comments and observing the suggestions
- Copilot can be customized through RStudio’s settings
Where Do We Need AI Support?
- AI assistants excel at generating boilerplate code, completing syntax, and helping with documentation
- Use caution with complex logic, project-specific requirements, and security-critical code
- Always review and test AI-generated code thoroughly
- AI assistants are tools to augment, not replace, human expertise
- Develop a balanced approach that leverages AI strengths while maintaining code quality and security
- Stay open to learning and adapting as AI technologies evolve
Risks, Drawbacks and Responsibilities with AI Usage
- AI can generate incorrect, insecure, or inefficient code - always verify
- You are fully responsible for all code you commit, regardless of AI involvement
- AI usage is inappropriate for critical systems, novel algorithms, and learning fundamentals
- Heavy AI reliance can lead to skill atrophy and reduced code understanding
- LLMs produce wrong code because they pattern-match rather than understand
- Comprehensive testing, code review, and iterative refinement are essential
- Balance AI productivity gains with maintaining your programming skills
- Consider legal, ethical, and privacy implications of AI tool usage
- Treat AI as a junior assistant requiring supervision, not an expert to trust blindly
- Responsible AI usage requires continuous learning and critical thinking
RStudio Autocompletion with Copilot
- Copilot generates suggestions based on context from your code and comments
- Write clear, descriptive comments to get better suggestions
- Use Tab to accept, and Esc to dismiss suggestions
- Break complex tasks into smaller steps for more accurate suggestions
- Always review and test AI-generated code before using it
- Combine Copilot assistance with your own coding expertise for best results
Context Definition and the AGENTS.md Concept
- Context definitions help AI assistants generate code that matches your project standards
- Context improves consistency: AI-generated code matches your project standards
-
AGENTS.mdprovides a standardized, version-controlled, machine-readable way to specify coding guidelines - Multiple
AGENTS.mdfiles can exist at different hierarchy levels; AI assistants use the closest file - Effective
AGENTS.mdfiles include clear examples of preferred and forbidden patterns - Start simple and iterate: Begin with core principles and expand based on needs
- Combining
AGENTS.mdwith inline comments, chat instructions, and tooling creates robust context - R projects benefit from explicit tidyverse usage and piping conventions in context definitions
Using AI within Pipelines via ellmer
-
ellmerprovides a unified interface for integrating LLMs into R workflows - Set up authentication using environment variables for security
- Integrate AI prompts seamlessly into tidyverse pipelines
- Design clear, constrained prompts for consistent results
- Implement error handling and caching for robust pipelines
- Document models and prompts for reproducibility
- Consider rate limits, costs, and ethical implications when using AI in data processing
- Local model options are available for high-volume use cases
Understanding and Setting LLM Parameters
- LLMs generate text through repeated token probability calculations and random selection
- Temperature controls the randomness of outputs: low values are more deterministic, high values are more creative
- Top-K and top-P sampling limit token selection to reduce nonsensical outputs
- Seeds enable reproducible results when using the same prompt and parameters
- Use
params()in ellmer to configure temperature, top_p, seed, and other parameters - For data processing, use low temperature (0.1-0.3) and set seed for reproducibility
- Document parameter choices and model versions for transparent, reproducible research
- Test parameter settings on sample data before processing full datasets
- Combine appropriate parameters with clear prompts for best results
Revise Your Code with AI
- AI chat interfaces provide valuable code review assistance
- Use iterative refinement: review, improve, and re-review
- Ask specific questions about correctness, performance, and style
- Always validate and test AI suggestions before accepting them
- Combine AI review with human peer review and automated tools
- Be aware of AI limitations and seek human expertise for critical code
- Document the review process and improvements made
GitHub Issue-Driven Coding with Copilot
- Issue-driven development provides structure and context for AI-assisted coding
- Detailed issues with clear requirements help AI assistants generate better code
- Reference issue numbers in commits, comments, and code to maintain traceability
- Use issues to guide Copilot for autonomous code generation and review
- Effective use of GitHub repositories and RStudio projects enhances collaboration and version control
- If not familiar with
git, read “Happy Git and GitHub for the useR” for a gentle introduction
Wrap-Up and Next Steps
- Always verify AI suggestions—you are responsible for all code you commit
- Use AI strategically: excel at boilerplate and documentation, avoid critical algorithms
- Write clear prompts and provide context for better AI suggestions
- Structure work with GitHub issues to guide AI effectively
- AI applications extend beyond code completion to testing, documentation, and project management
- The AI landscape evolves rapidly—stay current through communities and experimentation
- Human expertise, judgment, and creativity remain essential
- Balance AI assistance with skill maintenance to avoid over-dependence
- Treat AI as a powerful tool that amplifies your capabilities, not a replacement