| 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 |
This agent generates intelligent visualizations based on data characteristics and user preferences, with plots displayed directly in the chat interface.
x %||% yx %||% y
Add message to conversation history
add_to_conversation_history(role, message)add_to_conversation_history(role, message)
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
ai_addin_viewer(port = NULL)ai_addin_viewer(port = NULL)
port |
Port for the local plumber server (default: auto-detect) |
AI-driven code insertion with intelligent placement
ai_insert_code(code, context_context = NULL)ai_insert_code(code, context_context = NULL)
code |
The code to insert |
context_context |
Optional context to help determine placement |
AI-driven code replacement
ai_replace_code(old_code_pattern, new_code)ai_replace_code(old_code_pattern, new_code)
old_code_pattern |
Pattern to identify code to replace |
new_code |
The replacement code |
Smart code insertion with AI context
ai_smart_insert(code, location_hint = NULL)ai_smart_insert(code, location_hint = NULL)
code |
The code to insert |
location_hint |
Optional hint about where to insert |
Main plot analysis function
analyze_last_plot()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
analyze_visualization_plot(plot_command, plot_type, data_variables)analyze_visualization_plot(plot_command, plot_type, data_variables)
Auto-capture error context and show notification
auto_capture_error()auto_capture_error()
Capture current workspace context
Capture current workspace context
capture_context() capture_context()capture_context() capture_context()
Capture current workspace context with smart filtering
capture_context_smart(query = NULL)capture_context_smart(query = NULL)
Smart context capture with incremental processing
capture_context_smart_incremental(query = NULL)capture_context_smart_incremental(query = NULL)
Capture last error with context and code
Capture error after it occurs
capture_last_error() capture_last_error()capture_last_error() capture_last_error()
List containing error information and context
Detect changes between two context states
detect_context_changes(old_context, new_context)detect_context_changes(old_context, new_context)
old_context |
Previous context state |
new_context |
Current context state |
List of detected changes
Execute code directly in R console
execute_code(code)execute_code(code)
code |
The code to execute |
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
execute_code_in_session(code, settings = NULL)execute_code_in_session(code, settings = NULL)
code |
The R code to execute |
settings |
The current settings for execution |
This function executes the provided R code in the global environment and captures both the result and any output using proven methods.
A list containing the execution result and metadata
Execute analysis commands and collect results
execute_plot_analysis(commands)execute_plot_analysis(commands)
Execute R function directly from frontend
execute_r_function(function_name, param1, param2 = NULL)execute_r_function(function_name, param1, param2 = NULL)
function_name |
Name of the R function to call |
param1 |
First parameter |
param2 |
Second parameter |
Execute code with auto-capture
execute_with_capture(code)execute_with_capture(code)
Extract keywords from user query
extract_keywords(query)extract_keywords(query)
Extract data variables from plot command
extract_plot_data(command, plot_type)extract_plot_data(command, plot_type)
Find exact matches for keywords in object names
find_exact_matches(keywords, objects)find_exact_matches(keywords, objects)
Update workspace index Find the last plot command in R history
find_last_plot_command()find_last_plot_command()
Find partial and fuzzy matches for keywords in object names
find_partial_matches(keywords, objects)find_partial_matches(keywords, objects)
Generate analysis commands based on plot type
generate_analysis_commands(plot_type, data_var)generate_analysis_commands(plot_type, data_var)
Get Available DataFrames in Global Environment
get_available_dataframes()get_available_dataframes()
Character vector of DataFrame names
Get the console lines above the error
get_console_context()get_console_context()
Get conversation history as formatted string
get_conversation_history()get_conversation_history()
Get Basic Information About a DataFrame
get_dataframe_info(dataframe_name)get_dataframe_info(dataframe_name)
df_name |
Name of the DataFrame |
List with DataFrame information
Get the last executed code from R history
get_last_executed_code()get_last_executed_code()
Get relevant context from index based on error type
get_relevant_context_for_error(error_code, error_message)get_relevant_context_for_error(error_code, error_message)
Get RStudio theme information
get_rstudio_theme()get_rstudio_theme()
List containing theme information
Identify plot type from command
identify_plot_type(command)identify_plot_type(command)
Insert code into active document
insert_code(code = NULL)insert_code(code = NULL)
code |
The code to insert (if NULL, reads from clipboard) |
Insert code at specific location in document
insert_code_at_location( code, file_path = NULL, line_number = NULL, replace_selection = FALSE )insert_code_at_location( code, file_path = NULL, line_number = NULL, replace_selection = FALSE )
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
launch_html_interface()launch_html_interface()
Backwards compatibility alias
launch_websocket_chat()launch_websocket_chat()
Load execution settings
load_execution_settings()load_execution_settings()
A list containing execution settings
Log code to file
log_code_to_file(code, log_path)log_code_to_file(code, log_path)
code |
The R code to log |
log_path |
The path to the log file |
Invisible NULL
Log error to file
log_error_to_file(code, error_message, log_path)log_error_to_file(code, error_message, log_path)
code |
The R code that caused the error |
error_message |
The error message |
log_path |
The path to the log file |
Invisible NULL
Reconstruct multi-line base R plot command (plot, hist, boxplot, barplot)
reconstruct_base_plot_command(history_lines, start_line, plot_cmd)reconstruct_base_plot_command(history_lines, start_line, plot_cmd)
Reconstruct multi-line ggplot2 command
reconstruct_ggplot_command(history_lines, start_line)reconstruct_ggplot_command(history_lines, start_line)
Reconstruct base R QQ plot command possibly spanning multiple lines
reconstruct_qq_command(history_lines, start_line)reconstruct_qq_command(history_lines, start_line)
Refresh context and send to backend
refresh_context()refresh_context()
Remove error monitoring task callback
remove_error_monitoring()remove_error_monitoring()
Launch the AI assistant in RStudio viewer One-command solution that opens the HTML interface connected to Render backend
Launch Rgent
run_rgent() run_rgent()run_rgent() run_rgent()
Save execution settings
save_execution_settings(settings)save_execution_settings(settings)
settings |
A list containing execution settings |
Invisible NULL
Send debug error to AI for analysis
send_error_to_ai(error_details)send_error_to_ai(error_details)
Smart filtering functions for workspace objects
smart_filter_objects(query, objects)smart_filter_objects(query, objects)
Start WebSocket server for R-JavaScript communication
start_websocket_server()start_websocket_server()
Stop WebSocket server
stop_websocket_server()stop_websocket_server()
Test auto-capture system
test_auto_capture()test_auto_capture()
Toggle auto-fix mode (removed)
toggle_auto_fix()toggle_auto_fix()
Manually trigger auto-capture
trigger_auto_capture()trigger_auto_capture()
Full workspace update (fallback)
update_workspace_index_full()update_workspace_index_full()
Incremental workspace update functions
update_workspace_index_incremental()update_workspace_index_incremental()