refactor {TheOpenAIR} | R Documentation |
Refactor R Code with AI Assistance
Description
This function refactors R code with the assistance of an AI chatbot.
Usage
refactor(file, ...)
Arguments
file |
character, file name of a file containing R code to be refactored or a character string containing R code to be refactored |
... |
optional arguments to be passed to the chat_completion function |
Value
The refactored code either to the console (if the input 'file' was a character string) or written to a file (if the input was a file name).
Examples
## Not run:
# Create a sample R function file
cat("my_sum <- function(a, b) {", "return(a + b)", "}", file = "sample_function.R")
# Refactor the R function and return the output
refactored_function <- refactor(file = "sample_function.R")
# Refactor the R function and write the output to the same file
refactor(file = "sample_function.R")
## End(Not run)
[Package TheOpenAIR version 0.1.0 Index]