git clone https://github.com/revodavid/copilot-for-r
Install Visual Studio Code and R
In VS code:
- Install Copilot extension
- Install R Extension for Visual Studio Code
- To focus on copilot suggestions, change these settings:
- Editor > Hover (disabled)
- Editor > Quick Suggestions (off)
- Editor > Parameter Hints (disabled)
In R:
- Install packages: httr, jsonlite, tidyverse, tidymodels, docopt, httpuv
- OPTIONAL: options(vsc.dev.args = list(width = 800, height = 600)) # for easier to read plots
In root folder of repo:
- Create the file openai_key.txt containing only your OpenAI API key
- In Azure OpenAI Service, click on "Keys and Endpoint" and copy the key
Open pumpkins.R
and delete the contents. You can print it out or display it in an unsaved window to help you, but if you leave the contents in a file Copilot will use it to suggest its prompts.
Follow the path in the demo video "Copilot with R" linked in Readme.md.
You will need an Azure OpenAI API Service subscription. If you don't have one, visit the Azure OpenAI Service product page and scroll to the section "How do I access Azure OpenAI Service?" near the bottom of the page.
If you have access to the OpenAI API Service, you can easily modify the script to use it.
Open the file openai-sample-script.R
and run the R code.
Follow the path in the demo video "Azure OpenAI Service API" linked in Readme.md.