Copilot for R

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

It was my great pleasure to present last week to the NYC Data Hackers on the topic of Copilot for R. If you haven't come across Copilot before, it's like an AI-based pair programmer that suggests new lines of code, and perhaps entire functions, based on context. In the presentation (video below) I showed how while I was editing in Visual Studio Code with Copilot enabled, it suggested tidyverse functions for cleaning a data set, and even the code for performing an analysis of variance:

I also took a behind-the-scenes look to see how Copilot uses Generative AI to make its suggestions. With the Azure OpenAI Service, you can access the underlying OpenAI Codex model directly, and generate code suggestions via its API. I showed an R script to access the OpenAI API directly using the httr2 package, and also provided an R function to call an OpenAI model. We also had some fun with the text-based GPT3 model to generate a poem about Python and to suggest a funny cat name token by token.

Thanks to everyone who attended the talk and asked such awesome questions! If you missed it, the video is above and all the code, links and resources can be found in the GitHub repo linked below.

GitHub (revodavid): Copilot for R

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)