Polish programming
This commit is contained in:
parent
24caeb51e8
commit
2b189c9972
15
program.qmd
15
program.qmd
|
@ -45,14 +45,13 @@ In the following three chapters, you'll learn skills that will allow you to both
|
|||
|
||||
1. Copy-and-paste is a powerful tool, but you should avoid doing it more than twice.
|
||||
Repeating yourself in code is dangerous because it can easily lead to errors and inconsistencies.
|
||||
Instead, in [Chapter -@sec-functions], you'll learn how to write **functions** which let you extract out repeated code so that it can be easily reused.
|
||||
Instead, in @sec-functions, you'll learn how to write **functions** which let you extract out repeated code so that it can be easily reused.
|
||||
|
||||
2. As you start to write more powerful functions, you'll need a solid grounding in R's **data structures**, provided by vectors, which we discuss in [Chapter -@sec-vectors].
|
||||
You must master the four common atomic vectors, the three important S3 classes built on top of them, and understand the mysteries of the list and data frame.
|
||||
2. As you start to write more powerful functions, you'll need a solid grounding in R's **data structures**, provided by vectors, which we discuss in @sec-vectors. You must master the four common atomic vectors, the three important S3 classes built on top of them, and understand the mysteries of the list and data frame.
|
||||
|
||||
3. Functions extract out repeated code, but you often need to repeat the same actions on different inputs.
|
||||
You need tools for **iteration** that let you do similar things again and again.
|
||||
These tools include for loops and functional programming, which you'll learn about in [Chapter -@sec-iteration].
|
||||
These tools include for loops and functional programming, which you'll learn about in @sec-iteration.
|
||||
|
||||
A common theme throughout these chapters is the idea of reducing duplication in your code.
|
||||
Reducing code duplication has three main benefits:
|
||||
|
@ -65,12 +64,12 @@ Reducing code duplication has three main benefits:
|
|||
3. You're likely to have fewer bugs because each line of code is used in more places.
|
||||
|
||||
One tool for reducing duplication is functions, which reduce duplication by identifying repeated patterns of code and extract them out into independent pieces that can be easily reused and updated.
|
||||
Another tool for reducing duplication is **iteration**, which helps you when you need to do the same thing to multiple inputs: repeating the same operation on different columns, or on different datasets.
|
||||
Another tool for reducing duplication is iteration, which helps you when you need to do the same thing to multiple inputs: repeating the same operation on different columns, or on different datasets.
|
||||
|
||||
## Learning more
|
||||
|
||||
The goal of these chapters is to teach you the minimum about programming that you need to practice data science, which turns out to be a reasonable amount.
|
||||
Once you have mastered the material in this book, we strongly believe you should invest further in your programming skills.
|
||||
The goal of these chapters is to teach you the minimum about programming that you need to practice data science.
|
||||
Once you have mastered the material in this book, we strongly believe you should continue to invest in your programming skills.
|
||||
Learning more about programming is a long-term investment: it won't pay off immediately, but in the long term it will allow you to solve new problems more quickly, and let you reuse your insights from previous problems in new scenarios.
|
||||
|
||||
To learn more you need to study R as a programming language, not just an interactive environment for data science.
|
||||
|
@ -84,4 +83,4 @@ We have written two books that will help you do so:
|
|||
- [*Advanced R*](https://adv-r.hadley.nz/) by Hadley Wickham.
|
||||
This dives into the details of R the programming language.
|
||||
This is a great place to start if you have existing programming experience.
|
||||
It's also a great next step once you've internalised the ideas in these chapters.
|
||||
It's also a great next step once you've internalized the ideas in these chapters.
|
||||
|
|
Loading…
Reference in New Issue