Learn R Programming

chatAI4R (version 0.3.6)

convertRscript2Function: convertRscript2Function

Description

Convert selected R script to an R function using LLM.

Usage

convertRscript2Function(
  Model = "gpt-4o-mini",
  SelectedCode = TRUE,
  verbose = TRUE
)

Value

Inserts the converted function into the RStudio editor if `SelectedCode` is TRUE, otherwise writes to clipboard.

Arguments

Model

The OpenAI GPT model to use for text generation. Default is "gpt-4o-mini".

SelectedCode

Logical flag to indicate whether to use selected code in RStudio. Default is TRUE.

verbose

A logical value indicating whether to print the result to the console, default is TRUE.

Author

Satoshi Kume

Details

Convert Selected R Script to R Function

This function takes a selected portion of an R script and converts it into an R function. The function uses the OpenAI GPT model for text generation to assist in the conversion. The function can either take the selected code from the RStudio environment or from the clipboard.

Examples

Run this code
if (FALSE) {
# Option 1
# Select some text in RStudio and then run the rstudio addins
# Option 2
# Copy the text into your clipboard then execute
convertRscript2Function(Model = "gpt-4o-mini", SelectedCode = F)
}

Run the code above in your browser using DataLab