background picture with networks
Module 1 | Lesson 9

Split your work

Working with a monolithic 2000-line script can be overwhelming and inefficient 😱.

This lesson delves into the drawbacks of such an approach and offers practical strategies for dividing your work into manageable, coherent segments.

Members only
11 minutes read

Too long is too long

I am sure it already happened to you.

You write some code to analyse a dataset. It triggers some new questions. So you add some more code to understand. And so on!

You end up with a 2000 lines long file that takes 35 minutes to run from start to end.

This is annoying!

Slow: when you open R again to modify the end of your script, you have to run the beginning again!

Hard to maintain: navigating a 2000 lines long file is not fun at all.

Bad for collaboration: if you are several people working on the same massive file, it is very likely that you get conflicts.


So. How can you do?

➡️ You have to modularize your code.

And there are 3 main ways to do so:

1️⃣ Use Functions. Source() them.

In the previous lesson we saw how to avoid duplication in code by using functions.

background picture with networks
Productive R Workflow

This lesson is not ready yet! 🙃
Become a member now: you'll be the first accessing it, at a very preferential price.

Or Login

← Previous

Create functions. Ditch duplication.

Next →

Use shortcuts