Skip to content

Commit

Permalink
Merge branch 'origin/content-changes' into gh-pages
Browse files Browse the repository at this point in the history
Includes commits from #13 which weren't in 2445236
  • Loading branch information
katrinleinweber committed Apr 10, 2019
2 parents c123158 + ebf951b commit 7870a80
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 73 deletions.
54 changes: 6 additions & 48 deletions _episodes/03-func-R.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ it is mathematically correct by using `min`, `max`, and `plot`.
[start-ep]: {{ page.root }}/02-starting-with-data/



### Defining defaults

We have passed arguments to functions in two ways: directly, as in `dim(dat)`, and by name, as in `read.csv(file = "inflammation.csv", header = FALSE)`.
Expand Down Expand Up @@ -699,60 +698,19 @@ This is handy: if we usually want a function to work one way, but occasionally n


~~~
answer <- rescale2(v = dat[, 4], lower = 2, upper = 5)
min(answer)
~~~
{: .language-r}



~~~
[1] 2
~~~
{: .output}



~~~
max(answer)
rescale2(v = dat[, 4], lower = 2, upper = 5))
rescale2(dat[, 4], -5, -2))
~~~
{: .language-r}



~~~
[1] 5
~~~
{: .output}



~~~
answer <- rescale2(dat[, 4], -5, -2)
min(answer)
Error: <text>:1:45: unexpected ')'
1: rescale2(v = dat[, 4], lower = 2, upper = 5))
^
~~~
{: .language-r}



~~~
[1] -5
~~~
{: .output}



~~~
max(answer)
~~~
{: .language-r}



~~~
[1] -2
~~~
{: .output}
{: .error}

Compare both `rescale2` calls: Which is more understandable? Although passing
arguments purely by position is very convenient, because you have to type less,
Expand Down
9 changes: 4 additions & 5 deletions _episodes/04-making-packages-R.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ search()

This means you can now take
advantage of the console's auto-complete just like for any other package. Type
`cen` and/or `resc`, press <kbd>Tab</kbd> and test some examples like `center(c(1, 2, 3))` or
`cen` and/or `resc`, then <kbd>Tab</kbd> and test some examples like `center(c(1, 2, 3), 0)` or
`rescale(c(1, 2, 3))`.

## Folder and file structure of an R package
Expand Down Expand Up @@ -144,10 +144,9 @@ The package name can only contain letters and numbers and has to start with a le
> > The date is added in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format:
> > `date: 2018-07-12`.
> >
> > Before inserting the ORCiD, we have to merge the `Author` and `Maintainer`
> > fields into a machine-readable `Authors@R` field using the `person(…)`.
> > function. Look up its help page and convert your information.
> > Afterwards, add your ORCiD as a `comment = c(ORCID = "…")`.
> > ORCiDs can only be added to machine-readable `Authors@R` fields
> > that use the `person(…)` function. `use_description()` created this
> > already, so that you can add your ORCiD as a `comment = c(ORCID = "…")`.
> {: .solution}
>
> In summary: Enabling `citation()` to convert `DESCRIPTION` into a rich BibTeX
Expand Down
12 changes: 12 additions & 0 deletions _episodes/06-tidy-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ dataset about inflammation in 60 patients measured over 40 days. Let's pretend
we need to tidy it up for further publication alongside the package we have been
constructing.

> ## Staying in spreadsheets
> It is not always possible to abandon Excel & Co. and switch to R or Python.
> In order to learn more about how to organise data in spreadsheets, please read
> [DataCarpentry.org/spreadsheets-socialsci](https://datacarpentry.org/spreadsheets-socialsci/)
> and/or [DataCarpentry.org/spreadsheet-ecology-lesson](https://datacarpentry.org/spreadsheet-ecology-lesson/).
{: .callout}

First, run `library(usethis)` and `use_data_raw()` and note the `Next:` instructions
in the console. In particular, copy the `inflammation.csv` file to `data-raw`
and start a `tidy-inflammation.R` file there to which you add the necessary lines
Expand Down Expand Up @@ -277,6 +284,11 @@ in their own ways. Two useful tools to find structural problems in CSVs are
> {: .solution}
{: .challenge}

## [Reusing and citing public datasets](https://tibhannover.github.io/2018-07-09-FAIR-Data-and-Software/FAIR-remix-PANGAEA/)

This is a bonus episode that shows how FAIR datasets, together with the right mindset
of finding and reusing existing R code can help you in scientific data analyses.

[csvl]: https://csvlint.io/
[gt]: https://try.goodtables.io/
[RFC 4180]: https://tools.ietf.org/html/rfc4180
18 changes: 3 additions & 15 deletions _episodes_rmd/03-func-R.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,6 @@ it is mathematically correct by using `min`, `max`, and `plot`.

[start-ep]: {{ page.root }}/02-starting-with-data/

```{r rescale-test1, include=FALSE}
answer <- rescale(dat[, 4])
min(answer)
max(answer)
plot(answer)
plot(dat[, 4], answer) # This hasn't been introduced yet, but it may be
# useful to show when explaining the answer.
```

### Defining defaults

Expand Down Expand Up @@ -525,13 +517,9 @@ rescale2 <- function(v, lower = 0, upper = 1) {
}
```

```{r rescale-test2}
answer <- rescale2(v = dat[, 4], lower = 2, upper = 5)
min(answer)
max(answer)
answer <- rescale2(dat[, 4], -5, -2)
min(answer)
max(answer)
```{r rescale-test}
rescale2(v = dat[, 4], lower = 2, upper = 5))
rescale2(dat[, 4], -5, -2))
```

Compare both `rescale2` calls: Which is more understandable? Although passing
Expand Down
9 changes: 4 additions & 5 deletions _episodes_rmd/04-making-packages-R.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ search()

This means you can now take
advantage of the console's auto-complete just like for any other package. Type
`cen` and/or `resc`, press <kbd>Tab</kbd> and test some examples like `center(c(1, 2, 3))` or
`cen` and/or `resc`, then <kbd>Tab</kbd> and test some examples like `center(c(1, 2, 3), 0)` or
`rescale(c(1, 2, 3))`.

## Folder and file structure of an R package
Expand Down Expand Up @@ -143,10 +143,9 @@ The package name can only contain letters and numbers and has to start with a le
> > The date is added in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format:
> > `date: 2018-07-12`.
> >
> > Before inserting the ORCiD, we have to merge the `Author` and `Maintainer`
> > fields into a machine-readable `Authors@R` field using the `person(…)`.
> > function. Look up its help page and convert your information.
> > Afterwards, add your ORCiD as a `comment = c(ORCID = "…")`.
> > ORCiDs can only be added to machine-readable `Authors@R` fields
> > that use the `person(…)` function. `use_description()` created this
> > already, so that you can add your ORCiD as a `comment = c(ORCID = "…")`.
> {: .solution}
>
> In summary: Enabling `citation()` to convert `DESCRIPTION` into a rich BibTeX
Expand Down
12 changes: 12 additions & 0 deletions _episodes_rmd/06-tidy-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ dataset about inflammation in 60 patients measured over 40 days. Let's pretend
we need to tidy it up for further publication alongside the package we have been
constructing.

> ## Staying in spreadsheets
> It is not always possible to abandon Excel & Co. and switch to R or Python.
> In order to learn more about how to organise data in spreadsheets, please read
> [DataCarpentry.org/spreadsheets-socialsci](https://datacarpentry.org/spreadsheets-socialsci/)
> and/or [DataCarpentry.org/spreadsheet-ecology-lesson](https://datacarpentry.org/spreadsheet-ecology-lesson/).
{: .callout}

First, run `library(usethis)` and `use_data_raw()` and note the `Next:` instructions
in the console. In particular, copy the `inflammation.csv` file to `data-raw`
and start a `tidy-inflammation.R` file there to which you add the necessary lines
Expand Down Expand Up @@ -191,6 +198,11 @@ in their own ways. Two useful tools to find structural problems in CSVs are
> {: .solution}
{: .challenge}

## [Reusing and citing public datasets](https://tibhannover.github.io/2018-07-09-FAIR-Data-and-Software/FAIR-remix-PANGAEA/)

This is a bonus episode that shows how FAIR datasets, together with the right mindset
of finding and reusing existing R code can help you in scientific data analyses.

[csvl]: https://csvlint.io/
[gt]: https://try.goodtables.io/
[RFC 4180]: https://tools.ietf.org/html/rfc4180

0 comments on commit 7870a80

Please sign in to comment.