AI-enabled coding
When R throws red text at you, first determine what kind of message it is:
Removed 5 rows containing missing values). Action: Read it, verify if it affects your analysis, but no immediate panic.Don’t read the whole error if it looks messy. Look for the recognizable words at the end of the message.
Common Biomedical Data Errors translated to plain English:
Error: object 'XXX' not found
XXX yet, or you made a typo (e.g., you typed xxx).Error in read_csv("FILE") : could not find function "read_csv"
could not find functionlibrary(tidyverse) or library(readr) first.Error: unexpected symbol in "ggplot(data = clinical_df aes(x = treatment))"
unexpected symbolclinical_df).When the error is confusing, Large Language Models (LLMs) are your best teaching assistants. However, “Garbage In = Garbage Out.”
Bad example
My R code doesn’t work!!!!!
Asking right question
To get an immediate, accurate fix, always provide the AI with these three components:
Act as an expert R programmer
Goal: I am trying to [e.g., create a scatterplot of gene expression versus patient age using ggplot2].
Here is my code:
Here is the error message I received:
Please tell me what went wrong and provide the corrected code.
could not find function..., reply to the AI with that new error!str(your_data) or head(your_data) and mock up the values, or simply provide the column names.