| Title: | AI Assistant to Write and Understand R Code |
|---|---|
| Description: | An R console utility that lets you ask R related questions to the 'OpenAI' large language model. It can answer how-to questions by providing code, and what-is questions by explaining what given code does. You must provision your own key for the 'OpenAI' API <https://platform.openai.com/docs/api-reference>. |
| Authors: | Davis Vaughan [aut, cre], Soumya Ray [aut] |
| Maintainer: | Davis Vaughan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.3 |
| Built: | 2026-05-23 07:15:45 UTC |
| Source: | https://github.com/soumyaray/air |
Deletes your securely stored OpenAI API key and preferred model from your OS keyring.
delete_keyring_credentials()delete_keyring_credentials()
result list of success or failure class with:
status |
A character string of operation status. |
value |
A character string of descriptive message of status. |
# CAREFUL: Deletes OpenAI API key and preferred model from your OS keyring ## Not run: delete_keyring_credentials() ## End(Not run)# CAREFUL: Deletes OpenAI API key and preferred model from your OS keyring ## Not run: delete_keyring_credentials() ## End(Not run)
Ask OpenAI to write R code for a problem. The answer is written to console and returned as a string.
howto(do, call_api = call_openai)howto(do, call_api = call_openai)
do |
Character string of what you want to do |
call_api |
Optional function to call another API |
Invisible character string of R code
# You must provision an OpenAI API key before using this function. ## Not run: howto("read a csv file") howto("get last element of a vector") ## End(Not run)# You must provision an OpenAI API key before using this function. ## Not run: howto("read a csv file") howto("get last element of a vector") ## End(Not run)
Securely stores your your OpenAI API key to your OS keyring.
set_key(key = NULL)set_key(key = NULL)
key |
Optional string of your OpenAI API key; if not provided, a popup will ask you to enter it (safer). |
No return value; only side-effect and message printed to console
# CAREFUL: Changes your OpenAI API key in your OS keyring ## Not run: set_key("sk-my-api-key") # sets the key directly (will show in .Rhistory) set_key() # opens a system popup for secure entry ## End(Not run)# CAREFUL: Changes your OpenAI API key in your OS keyring ## Not run: set_key("sk-my-api-key") # sets the key directly (will show in .Rhistory) set_key() # opens a system popup for secure entry ## End(Not run)
Securely stores your your OpenAI API key to your OS keyring.
set_model(model = "gpt-4")set_model(model = "gpt-4")
model |
String of your preferred model; defaults to 'gpt-4'. |
No return value; only side-effect and message printed to console
# CAREFUL: Changes your OpenAI API model in your OS keyring ## Not run: set_model("gpt-4-1106-preview") set_model() # use default ## End(Not run)# CAREFUL: Changes your OpenAI API model in your OS keyring ## Not run: set_model("gpt-4-1106-preview") set_model() # use default ## End(Not run)
Ask OpenAI to explain what given R code does. The answer is written to console and returned as a string.
whatis(this, call_api = call_openai)whatis(this, call_api = call_openai)
this |
Character string of code to be explained |
call_api |
Optional function to call another API |
Invisible character string of explanation
# You must provision an OpenAI API key before using this function. ## Not run: whatis("paste0(vector1, vector2)") whatis("length(x) %% 2 == 1 ? x[(length(x) + 1) / 2] : NA") ## End(Not run)# You must provision an OpenAI API key before using this function. ## Not run: whatis("paste0(vector1, vector2)") whatis("length(x) %% 2 == 1 ? x[(length(x) + 1) / 2] : NA") ## End(Not run)