Skip to content

Commit

Permalink
Add commas
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Sep 28, 2024
1 parent d412b80 commit 063f14a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 05-geometry-operations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ A variety of georeferencing techniques exist, including:

- Georectification based on known [ground control points](https://www.qgistutorials.com/en/docs/3/georeferencing_basics.html)
- Orthorectification, which also accounts for local topography
- Image [registration](https://en.wikipedia.org/wiki/Image_registration) is used to combine images of the same thing but shot from different sensors by aligning one image with another (in terms of coordinate system and resolution)
- Image [registration](https://en.wikipedia.org/wiki/Image_registration) is used to combine images of the same thing, but shot from different sensors by aligning one image with another (in terms of coordinate system and resolution)

R is rather unsuitable for the first two points since these often require manual intervention which is why they are usually done with the help of dedicated GIS software (see also Chapter \@ref(gis)).
On the other hand, aligning several images is possible in R and this section shows among others how to do so.
Expand Down
6 changes: 3 additions & 3 deletions 11-algorithms.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The example also reflects a secondary aim of the chapter which, following @xiao_

If functions distributed in packages are the building blocks of R code, scripts are the glue that holds them together.
Scripts should be stored and executed in a logical order to create reproducible workflows\index{reproducibility}, manually or with workflow automation tools such as **targets** [@landau_targets_2021].
If you are new to programming scripts may seem intimidating when you first encounter them, but they are simply plain text files.
If you are new to programming, scripts may seem intimidating when you first encounter them, but they are simply plain text files.
Scripts are usually saved as a file with an extension representing the language they contain, such as `.py` for scripts written in Python or `.rs` for scripts written in Rust.
R scripts should be saved with a `.R` extension and named to reflect what they do.
An example is [`11-hello.R`](https://github.com/geocompx/geocompr/blob/main/code/11-hello.R), a script file stored in the [`code`](https://github.com/geocompx/geocompr/tree/main/code/) folder of the book's repository.
Expand All @@ -54,7 +54,7 @@ An example is [`11-hello.R`](https://github.com/geocompx/geocompr/blob/main/code
print("Hello geocompr")
```

The contents of this script are not particularly exciting but they demonstrate the point: scripts do not need to be complicated.
The contents of this script are not particularly exciting, but they demonstrate the point: scripts do not need to be complicated.
Saved scripts can be called and executed in their entirety from the R command line with the `source()` function, as demonstrated below.
The output of this command shows that the comment is ignored but `print()` command is executed:

Expand Down Expand Up @@ -441,7 +441,7 @@ This principle is explained with reference to the use of functions to reduce cod
2. [KISS](https://en.wikipedia.org/wiki/KISS_principle) (keep it simple stupid): this principle suggests that simple solutions should be tried first and preferred over complex solutions, using dependencies where needed, and aiming to keep scripts concise.
This principle is the computing analogy of the [quote](https://www.nature.com/articles/d41586-018-05004-4) "things should be made as simple as possible, but no simpler".
3. Modularity: your code will be easier to maintain if it's divided into well-defined pieces.
A function should do only one thing but do this really well.
A function should do only one thing, but do this really well.
If you function is becoming too long, think about splitting it into multiple small functions, each of which could be re-used for other purposes, supporting DRY and KISS principles.

We cannot guarantee that this chapter will instantly enable you to create perfectly formed functions for your work.
Expand Down

0 comments on commit 063f14a

Please sign in to comment.