GitHub Copilot on Posit Cloud

GitHub Copilot on Posit Cloud

Posit Cloud is an online platform that lets you organize data projects in an easy-to-use and collaborative environment. 

If you have access to GitHub Copilot, you can now experience AI code assistance within your RStudio projects on Posit Cloud.

See it in action:


What is GitHub Copilot?


GitHub Copilot is a popular AI development tool that can convert human language commands into executable code or speed up your coding with intelligent autocompletion.


Respond to a command


You can write a comment in RStudio that prompts Copilot to create something specific. Simply type in what you are looking to accomplish, such as a function that calculates area. When you press Return on the keyboard, you’ll find Copilot’s code recommendation in gray placeholder text.

Example GitHub Copilot code in Posit Cloud

Like what you see? Accept the suggestion by pressing the tab key and then run the code as you normally would. An AI-generated function named area is now available in your environment. 

You can then ask the AI to calculate the area for a specific set of measurements and Copilot will employ the formula that it created.

Example GitHub Copilot code in Posit Cloud

Autocomplete your work


Another opportunity is to use Copilot to speed up coding by taking advantage of real-time autocomplete recommendations. For example, simply start to type ggplot( and watch Copilot provide suggestions to build out a full visualization.

Example GitHub Copilot code in Posit Cloud

Here is what Copilot came up with.

ggplot2 output

Not exactly what you were looking for? Provide a new prompt to have Copilot make a more refined recommendation.

Example GitHub Copilot code in Posit Cloud

Here is Copilot’s new output:

Faceted ggplot graphs

Not a bad start, especially if you know enough R programming to build upon base recommendations, troubleshoot issues, and work together with Copilot to build something great.


How to set up Copilot on Posit Cloud


Assuming you already have access to Copilot from GitHub, getting set up in RStudio on Posit Cloud is quick and easy.

  1. Create a new RStudio Project.
  2. Go to Tools in the menu and select Global Options.
  3. Select the Copilot tab and check the checkbox to Enable GitHub Copilot.
  4. Click Install to install the agent in RStudio.
  5. Click the Sign In button that appears.
  6. Copy your verification code and then click the GitHub link. 
  7. Paste the code from Step 6 on the GitHub activation page, and click Continue.
  8. Agree to authorize the plugin.
  9. Close the page and return to Posit Cloud.

You are now ready to start using GitHub Copilot on Posit Cloud. Just open a new script and get started!


Things to keep in mind


GitHub Copilot needs to be enabled and authorized for each new project. You must have access to GitHub Copilot via your GitHub account, and you must authenticate with that account before you can use GitHub Copilot in your projects. GitHub Copilot is free for students and teachers.

You can learn more about using Copilot in the RStudio User Guide and discover other LLM IDE integrations made available through chattr.