1  Introduction

1.1 In this book

Whether you are an experienced R package developer looking to improve your workflow, or a data scientist interested in building packages to share your work with others, this book will provide valuable insights into how AI coding assistants can help you build your packages more efficiently. Specifically, we will go over ChatGPT and Github Copilot, two of the most popular AI coding assistants currently available. For the purposes of this book, we will consider AI pair programmers to also be AI coding assistants.

Chapter 2 will provide an overview of these tools. We will then dive into individual chapters on how these tools can assist with the development of functions in chapter 3, unit tests in chapter 4, and vignettes in chapter 5, providing practical examples and best practices along the way.

1.2 Prerequisites

We assume that the reader has prior experience developing R packages and is familiar with the basics of package development, including the use of devtools, usethis, roxygen2, and testthat. Additionally, we assume that the reader has already read R Packages by Hadley Wickham and Jenny Bryan, which provides an excellent introduction to R package development. Lastly, we assume that the reader has a good understanding of the R language and its ecosystem. This is important to recognize bugs or “hallucinations” generated by ChatGPT.

1.3 Philosophy

This book advocates for the use of AI code assistants to improve your productivity. However, it shouldn’t replace good understanding of your code and selected programming language. Developers should be aware of current common failures of systems they may be using. Also readers should be cautious about use of tools like ChatGPT to avoid learning.

1.4 Privacy

Ensure that you don’t provide AI code assistants such as ChatGPT or Github CoPilot with sensitive code or data. There have already been many cases of employees pasting sensitive data, and some estimates of how common this is. We’d recommend reading the privacy policy for the AI assistant that you’d using and recommend ensuring sensitive data is kept separate.

1.5 What you won’t learn

Here are some topics you won’t learn about in this book:

  • Developing your first R package
  • Creating a large language model like ChatGPT
  • Using AI code assistants for analysis with R

1.6 Colophon

This book was created using Quarto. The website is hosted on Github pages and the code is available on Github.

1.7 Ethical considerations

1.7.1 Risk of Plaigarism

Although there is evidence that AI code assistants can significantly improve productivity (a,b, or c), there have been cases of unintentional plagiarism or copyright violation associated with ChatGPT use that you should also be aware of when using such tools for niche cases:

Additionally, if you are using Github Copilot in an organization or business context, you may need confirm safe use with your IT department to and possibly updating your suggestion matching policies on public code.

1.8 Disclaimer

Please note that this book was written with assistance from ChatGPT because it’s only right that a book on the use of AI assistants was written with some help from ChatGPT. 😁