Code Editing

Describe what you want. AiR edits your code.

Tell AiR what to change in plain English. It reads your file, understands your project, and modifies code directly - showing you a diff before anything is applied.

Get Started Free
Natural Language

Just describe the change

AiR handles everything from small tweaks to structural refactors. Here are some examples of what you can ask.

U

Add input validation to check that df is a dataframe and has at least one row

utils/clean_data.R
+4-0
clean_data <- function(df, remove_na = TRUE) {
+ if (!is.data.frame(df)) stop("Input must be a dataframe")
+ if (nrow(df) == 0) stop("Dataframe has no rows")
+ 
df_clean <- df
if (remove_na) {
AcceptReject
U

Convert these for loops to purrr::map

analysis.R
+3-5
-results <- list()
-for (i in seq_along(datasets)) {
- results[[i]] <- run_model(datasets[[i]])
-}
-names(results) <- names(datasets)
+library(purrr)
+ 
+results <- map(datasets, run_model)
AcceptReject
U

Add roxygen documentation to this function

R/fit_model.R
+8-0
+#' Fit a linear model with cross-validation
+#'
+#' @param data A dataframe containing the variables
+#' @param formula A model formula (e.g., y ~ x1 + x2)
+#' @param folds Number of CV folds (default: 10)
+#' @return A list with model object and CV metrics
+#' @export
fit_model <- function(data, formula, folds = 10) {
ctrl <- trainControl(method = "cv", number = folds)
AcceptReject
Control

You decide what gets applied

Every edit goes through your approval. Accept the changes, reject them, or undo after accepting. You're always in control.

Accept

Apply the changes to your file. The diff is applied via RStudio's API, so your editor stays in sync - cursor position, undo history, everything.

Reject

Discard the proposed changes entirely. Your file remains untouched. Ask AiR to try a different approach, or modify your instructions.

Undo

Changed your mind after accepting? Click undo. AiR remembers the original state and reverts the change. Available until the next edit.

Context

Edits that understand your whole project

AiR doesn't edit in a vacuum. It reads your active file, knows your project structure, sees your loaded datasets, and understands package dependencies.

Active File

AiR reads the complete contents of your current file. It understands the surrounding code, existing functions, and data flow.

R Environment

Knows every loaded dataframe, their columns, types, and distributions. Edits that reference your data are contextually accurate.

Project Files

Sees your project structure - which files exist, what functions are defined where, and how files relate to each other.

Package Dependencies

Tracks which packages are loaded in your session. If an edit requires a new package, AiR adds the library() call.

Compatibility

Works with any R file

AiR edits are applied through RStudio's native API, so they work with any file type that RStudio supports.

.R

R Scripts

Standard R scripts. Functions, data pipelines, analysis code - all editable with natural language.

.Rmd

R Markdown

Edit both narrative text and code chunks. AiR understands the R Markdown structure and respects chunk boundaries.

.qmd

Quarto

Full support for Quarto documents. Edit YAML frontmatter, prose, and code chunks interchangeably.

Conversation

Refine edits through conversation

Not quite what you wanted? Keep talking. AiR remembers the conversation context and refines its edits based on your feedback.

U
Add error handling to the data loading function
I've wrapped the read_csv call in tryCatch with a meaningful error message. Here's the diff...
U
Good, but also add a check for the file existing first
Added file.exists() check before the read. If the file is missing, it now returns NULL with a warning instead of throwing an error.

Each message in the conversation carries full context - your file, your environment, and all previous edits. AiR refines without losing track.

Edit code at the speed of thought

Stop typing boilerplate. Describe what you need and let AiR handle the rest.