Skip to content
Join our email list to get $80 off Ally in November →
R for the Rest of Us Logo

Ally Lesson

Translate between base R and the tidyverse

Free preview: first minute

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

I'm much more comfortable with the tidyverse than base R, so when I get base R code from someone else I run into trouble reading it. I tried reading a script line by line, then had my agent comment it, and finally just asked it to translate the script into tidyverse.

You'll learn:

  • How to ask an AI agent to translate code from base R to tidyverse instead of trying to parse unfamiliar syntax by hand
  • How to have an agent add line-by-line comments to explain code you don't know well, and why a direct translation is often the better request
  • A way to check a translation by running the original and translated scripts and confirming the numbers match
  • How to use the same approach across languages, such as converting PHP and Laravel code into R so you can review what it does

Tools mentioned:

Key moments:

  • 00:03 Working with code written in an unfamiliar style
  • 00:34 Parsing base R code line by line
  • 00:50 Asking the agent to comment each line
  • 01:15 Deciding to translate instead of explain
  • 01:33 Agent creates a tidyverse version of the script
  • 01:44 Both scripts run and the numbers match
  • 01:52 Walkthrough of the changes: age groups and county summaries
  • 02:15 Translating between languages, PHP and Laravel to R
  • 02:44 Recommendation to ask the agent rather than translate by hand