@ggnot2

melissavanbussel.com

@melvanbussel

@melissavanbussel

github.com/melissavanbussel

Disclaimer

Do not use this at work!

GitHub Copilot is a “pair programmer” that generates code suggestions in real-time directly in RStudio

ChatGPT is more like a chatbot, where there’s back and forth conversation

Costing

GitHub Copilot: Flat-rate fee of $10/month


ChatGPT: Depends on how you use it!

  • In the browser: Free (exception: GPT-4)
  • In RStudio: Charge is proportional to the length of the conversation
  • Can set monthly spending caps

Using GitHub Copilot in RStudio

Using GitHub Copilot in RStudio

  • You can return to Tools > Global Options > Copilot at any time to disable Copilot in RStudio (or Ctrl+Shift+P and search for Copilot)

Using ChatGPT in RStudio

Many different options, but as of January 2024, I recommend chattr:

  • Maintained by Posit
  • Answers are more tailored:

Using ChatGPT in RStudio

> chattr(preview = TRUE)

── chattr ─────────────────────────────────────────────────────────

── Preview for: Console 
• Provider: Open AI - Chat Completions
• Path/URL: https://api.openai.com/v1/chat/completions
• Model: gpt-3.5-turbo
• temperature: 0.01
• max_tokens: 1000
• stream: TRUE

── Prompt: 
role: system
content: You are a helpful coding assistant
role: user
content:
* Use the 'Tidy Modeling with R' (https://www.tmwr.org/) book as
main reference
* Use the 'R for Data Science' (https://r4ds.had.co.nz/) book as
main reference
* Use tidyverse packages: readr, ggplot2, dplyr, tidyr
* For models, use tidymodels packages: recipes, parsnip,
yardstick, workflows, broom
* Avoid explanations unless requested by user, expecting code only
* For any line that is not code, prefix with a: #
* Keep each line of explanations to no more than 80 characters
* DO NOT use Markdown for the code
[Your future prompt goes here]

Setting up the chattr package

Install the package from GitHub:

remotes::install_github("mlverse/chattr")

Obtain an OpenAI API key:

Sys.setenv(OPENAI_API_KEY = "sk-...") # one-time only
# or usethis::edit_r_environ()
# or on Windows, "Edit the system environment variables"

You can now run the chattr_app() function to start chatting!