Package 'rstudioai'

Title: RgentAI: AI-Powered Statistical Analysis Assistant for R
Description: An intelligent AI assistant for R programming that provides conversational chat, plot analysis, error debugging, and specialized agents for data cleaning, transformation, statistical analysis, and machine learning workflows.
Authors: Nathan Bresette
Maintainer: Nathan Bresette <[email protected]>
License: MIT + file LICENSE
Version: 2.4.16
Built: 2026-11-10 01:53:47 UTC
Source: https://github.com/NathanBresette/Rgent-AI

Help Index


Visualization Agent for RStudio AI

Description

This agent generates intelligent visualizations based on data characteristics and user preferences, with plots displayed directly in the chat interface.

Usage

x %||% y

Add message to conversation history

Description

Add message to conversation history

Usage

add_to_conversation_history(role, message)

Arguments

role

The role of the message sender ("user" or "ai")

message

The message content


Launch the AI assistant in the browser One-command solution that opens the HTML interface connected to Render backend

Description

Launch the AI assistant in the browser One-command solution that opens the HTML interface connected to Render backend

Usage

ai_addin_viewer(port = NULL)

Arguments

port

Port for the local plumber server (default: auto-detect)


AI-driven code insertion with intelligent placement

Description

AI-driven code insertion with intelligent placement

Usage

ai_insert_code(code, context_context = NULL)

Arguments

code

The code to insert

context_context

Optional context to help determine placement


AI-driven code replacement

Description

AI-driven code replacement

Usage

ai_replace_code(old_code_pattern, new_code)

Arguments

old_code_pattern

Pattern to identify code to replace

new_code

The replacement code


Smart code insertion with AI context

Description

Smart code insertion with AI context

Usage

ai_smart_insert(code, location_hint = NULL)

Arguments

code

The code to insert

location_hint

Optional hint about where to insert


Main plot analysis function

Description

Main plot analysis function

Usage

analyze_last_plot()

Analyze visualization agent plot specifically This function is designed for visualization agent plots and doesn't interfere with the analyze_last_plot button

Description

Analyze visualization agent plot specifically This function is designed for visualization agent plots and doesn't interfere with the analyze_last_plot button

Usage

analyze_visualization_plot(plot_command, plot_type, data_variables)

Auto-capture error context and show notification

Description

Auto-capture error context and show notification

Usage

auto_capture_error()

Capture current workspace context

Description

Capture current workspace context

Capture current workspace context

Usage

capture_context()

capture_context()

Capture current workspace context with smart filtering

Description

Capture current workspace context with smart filtering

Usage

capture_context_smart(query = NULL)

Smart context capture with incremental processing

Description

Smart context capture with incremental processing

Usage

capture_context_smart_incremental(query = NULL)

Capture last error with context and code

Description

Capture last error with context and code

Capture error after it occurs

Usage

capture_last_error()

capture_last_error()

Value

List containing error information and context


Detect changes between two context states

Description

Detect changes between two context states

Usage

detect_context_changes(old_context, new_context)

Arguments

old_context

Previous context state

new_context

Current context state

Value

List of detected changes


Execute code directly in R console

Description

Execute code directly in R console

Usage

execute_code(code)

Arguments

code

The code to execute


R Code Execution Engine

Description

This module handles all R code execution using proven, reliable methods adapted from ClaudeR's execution approach. Execute R code in the active RStudio session

Usage

execute_code_in_session(code, settings = NULL)

Arguments

code

The R code to execute

settings

The current settings for execution

Details

This function executes the provided R code in the global environment and captures both the result and any output using proven methods.

Value

A list containing the execution result and metadata


Execute analysis commands and collect results

Description

Execute analysis commands and collect results

Usage

execute_plot_analysis(commands)

Execute R function directly from frontend

Description

Execute R function directly from frontend

Usage

execute_r_function(function_name, param1, param2 = NULL)

Arguments

function_name

Name of the R function to call

param1

First parameter

param2

Second parameter


Execute code with auto-capture

Description

Execute code with auto-capture

Usage

execute_with_capture(code)

Extract keywords from user query

Description

Extract keywords from user query

Usage

extract_keywords(query)

Extract data variables from plot command

Description

Extract data variables from plot command

Usage

extract_plot_data(command, plot_type)

Find exact matches for keywords in object names

Description

Find exact matches for keywords in object names

Usage

find_exact_matches(keywords, objects)

Update workspace index Find the last plot command in R history

Description

Update workspace index Find the last plot command in R history

Usage

find_last_plot_command()

Find partial and fuzzy matches for keywords in object names

Description

Find partial and fuzzy matches for keywords in object names

Usage

find_partial_matches(keywords, objects)

Generate analysis commands based on plot type

Description

Generate analysis commands based on plot type

Usage

generate_analysis_commands(plot_type, data_var)

Get Available DataFrames in Global Environment

Description

Get Available DataFrames in Global Environment

Usage

get_available_dataframes()

Value

Character vector of DataFrame names


Get the console lines above the error

Description

Get the console lines above the error

Usage

get_console_context()

Get conversation history as formatted string

Description

Get conversation history as formatted string

Usage

get_conversation_history()

Get Basic Information About a DataFrame

Description

Get Basic Information About a DataFrame

Usage

get_dataframe_info(dataframe_name)

Arguments

df_name

Name of the DataFrame

Value

List with DataFrame information


Get the last executed code from R history

Description

Get the last executed code from R history

Usage

get_last_executed_code()

Get relevant context from index based on error type

Description

Get relevant context from index based on error type

Usage

get_relevant_context_for_error(error_code, error_message)

Get RStudio theme information

Description

Get RStudio theme information

Usage

get_rstudio_theme()

Value

List containing theme information


Identify plot type from command

Description

Identify plot type from command

Usage

identify_plot_type(command)

Insert code into active document

Description

Insert code into active document

Usage

insert_code(code = NULL)

Arguments

code

The code to insert (if NULL, reads from clipboard)


Insert code at specific location in document

Description

Insert code at specific location in document

Usage

insert_code_at_location(
  code,
  file_path = NULL,
  line_number = NULL,
  replace_selection = FALSE
)

Arguments

code

The code to insert

file_path

Optional file path (if NULL, uses active document)

line_number

Optional line number (if NULL, uses cursor position)

replace_selection

Whether to replace current selection


Launch HTML interface with HTTPS support for clipboard API

Description

Launch HTML interface with HTTPS support for clipboard API

Usage

launch_html_interface()

Backwards compatibility alias

Description

Backwards compatibility alias

Usage

launch_websocket_chat()

Load execution settings

Description

Load execution settings

Usage

load_execution_settings()

Value

A list containing execution settings


Log code to file

Description

Log code to file

Usage

log_code_to_file(code, log_path)

Arguments

code

The R code to log

log_path

The path to the log file

Value

Invisible NULL


Log error to file

Description

Log error to file

Usage

log_error_to_file(code, error_message, log_path)

Arguments

code

The R code that caused the error

error_message

The error message

log_path

The path to the log file

Value

Invisible NULL


Reconstruct multi-line base R plot command (plot, hist, boxplot, barplot)

Description

Reconstruct multi-line base R plot command (plot, hist, boxplot, barplot)

Usage

reconstruct_base_plot_command(history_lines, start_line, plot_cmd)

Reconstruct multi-line ggplot2 command

Description

Reconstruct multi-line ggplot2 command

Usage

reconstruct_ggplot_command(history_lines, start_line)

Reconstruct base R QQ plot command possibly spanning multiple lines

Description

Reconstruct base R QQ plot command possibly spanning multiple lines

Usage

reconstruct_qq_command(history_lines, start_line)

Refresh context and send to backend

Description

Refresh context and send to backend

Usage

refresh_context()

Remove error monitoring task callback

Description

Remove error monitoring task callback

Usage

remove_error_monitoring()

Launch the AI assistant in RStudio viewer One-command solution that opens the HTML interface connected to Render backend

Description

Launch the AI assistant in RStudio viewer One-command solution that opens the HTML interface connected to Render backend

Launch Rgent

Usage

run_rgent()

run_rgent()

Save execution settings

Description

Save execution settings

Usage

save_execution_settings(settings)

Arguments

settings

A list containing execution settings

Value

Invisible NULL


Send debug error to AI for analysis

Description

Send debug error to AI for analysis

Usage

send_error_to_ai(error_details)

Smart filtering functions for workspace objects

Description

Smart filtering functions for workspace objects

Usage

smart_filter_objects(query, objects)

Start WebSocket server for R-JavaScript communication

Description

Start WebSocket server for R-JavaScript communication

Usage

start_websocket_server()

Stop WebSocket server

Description

Stop WebSocket server

Usage

stop_websocket_server()

Test auto-capture system

Description

Test auto-capture system

Usage

test_auto_capture()

Toggle auto-fix mode (removed)

Description

Toggle auto-fix mode (removed)

Usage

toggle_auto_fix()

Manually trigger auto-capture

Description

Manually trigger auto-capture

Usage

trigger_auto_capture()

Full workspace update (fallback)

Description

Full workspace update (fallback)

Usage

update_workspace_index_full()

Incremental workspace update functions

Description

Incremental workspace update functions

Usage

update_workspace_index_incremental()