Copy, paste, and tweak

advice
Posted

Saturday September 6, 2025 at 3:58 PM

Learning programming is a little different from learning other skills or materials. In other classes you’ve taken, you read articles or textbooks, take notes on them, talk about the readings in class, maybe complete problem sets or exercises about the materials, and then you take a test.

With programming, though, the approach is typically different. You read things, you copy code, you paste that code into a file on your computer, and you tinker with the code to see how it works and what changes as you change things.

The R community in particular has embraced this approach to learning how to code. Posit, the company that develops RStudio, has a whole team of professional educators dedicated to improving R pedagogy, and they use this approach in all their teaching materials. The Software Carpentry project (a group dedicated to teaching data and programming skills) does too. I’m a fan of it as well. As one of the textbooks I teach from in another class states:

Take the “copy, paste, and tweak” approach: Especially when you learn your first programming language or you need to understand particularly complicated code, it is often much easier to take existing code that you know works and modify it to suit your ends. This is as opposed to trying to type out the code from scratch. We call this the “copy, paste, and tweak” approach. So early on, we suggest not trying to write code from memory, but rather take existing examples we have provided you, then copy, paste, and tweak them to suit your goals. After you start feeling more confident, you can slowly move away from this approach and write code from scratch. Think of the “copy, paste, and tweak” approach as training wheels for a child learning to ride a bike. After getting comfortable, they won’t need them anymore.

To make your copying/pasting life easier, each session has an extensive example page and an accompanying video showing how to create the different visualizations. Copy/paste/tweak liberally from the example pages!

Every chunk of code on the course website has a neat little clipboard icon that you can use to copy the whole chunk:

# Click on the clipboard icon in the top right corner → to copy this code
x <- 1:5
x + 5
## [1]  6  7  8  9 10

Use that button!

This is also why I have you do stuff in Quarto. Everything in your exercises is completely reproducible. The document tells you exactly what you ran to get the data and results and figures that you made. Copy and paste from your past assignments liberally. Copy and paste from the examples liberally.

Do not be super noble and force yourself to write everything from scratch!

Finally, if you ever get frustrated when running code or making a plot because it goes wild and vomits geoms all over the page, don’t worry! It happens to everyone! There’s actually a whole hashtag for #accidentalaRt where people post their plotting disasters. Scroll through the feed at Bluesky or LinkedIn and see the marvelous accidental art people make. It’s fantastic.