Skip to content

Commit

Permalink
differences for PR #18
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 18, 2023
1 parent 69d7788 commit d3da837
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 199 deletions.
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Contributor Code of Conduct
title: "Contributor Code of Conduct"
---

As contributors and maintainers of this project,
Expand All @@ -8,6 +8,6 @@ we pledge to follow the [The Carpentries Code of Conduct][coc].
Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by following our [reporting guidelines][coc-reporting].

[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html

[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html
[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html
12 changes: 4 additions & 8 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Licenses
title: "Licenses"
---

## Instructional Material
Expand All @@ -24,7 +24,7 @@ Under the following terms:

- **Attribution**---You must give appropriate credit (mentioning that your work
is derived from work that is Copyright (c) The Carpentries and, where
practical, linking to https\://carpentries.org/), provide a [link to the
practical, linking to <https://carpentries.org/>), provide a [link to the
license][cc-by-human], and indicate if changes were made. You may do so in
any reasonable manner, but not in any way that suggests the licensor endorses
you or your use.
Expand All @@ -35,10 +35,10 @@ Under the following terms:

Notices:

- You do not have to comply with the license for elements of the material in
* You do not have to comply with the license for elements of the material in
the public domain or where your use is permitted by an applicable exception
or limitation.
- No warranties are given. The license may not give you all of the permissions
* No warranties are given. The license may not give you all of the permissions
necessary for your intended use. For example, other rights such as publicity,
privacy, or moral rights may limit how you use the material.

Expand Down Expand Up @@ -73,11 +73,7 @@ Carpentry" and their respective logos are registered trademarks of [Community
Initiatives][ci].

[cc-by-human]: https://creativecommons.org/licenses/by/4.0/

[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode

[mit-license]: https://opensource.org/licenses/mit-license.html

[ci]: https://communityin.org/

[osi]: https://opensource.org
58 changes: 29 additions & 29 deletions basic-targets.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
---
title: 初めてのtargetsによるワークフロー
title: 'First targets Workflow'
teaching: 10
exercises: 2
---

:::::::::::::::::::::::::::::::::::::: questions
:::::::::::::::::::::::::::::::::::::: questions

- 解析を整理するためのベストプラクティスは?
- `_targets.R`ファイルは何に使うのか?
- `_targets.R`ファイルの内容は?
- ワークフローはどのように実行出来るのか?
- What are best practices for organizing analyses?
- What is a `_targets.R` file for?
- What is the content of the `_targets.R` file?
- How do you run a workflow?

::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: objectives

- RStudio でプロジェクトを作成する
- `_targets.R`ファイルの目的を説明する
- 基本的な `_targets.R` ファイルを書く
- `_targets.R` ファイルを使用してワークフローを実行する
- Create a project in RStudio
- Explain the purpose of the `_targets.R` file
- Write a basic `_targets.R` file
- Use a `_targets.R` file to run a workflow

::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: {.instructor}

エピソードの概要:まずはシンプルなワークフローを書くことで慣らしてもらう
Episode summary: First chance to get hands dirty by writing a very simple workflow

:::::::::::::::::::::::::::::::::::::



## プロジェクトの作成
## Create a project

### プロジェクトについて
### About projects

`targets` は、分析を整理するために「プロジェクト」という概念を採用しています。あるプロジェクトに必要なファイルはすべて、プロジェクトフォルダという1つのフォルダに収められます。
プロジェクトフォルダには、データ、コード、結果用のフォルダなど、整理のためのサブフォルダも追加可能です。
`targets` uses the "project" concept for organizing analyses: all of the files needed for a given project are put in a single folder, the project folder.
The project folder has additional subfolders for organization, such as folders for data, code, and results.

プロジェクトを使用することによって、別のプロジェクト(解析)から戻って来た際、迷わずに中断したところから再開することができます。
何かをやり始めたら完成するまで他のことに一切手を出さないなら、このような問題は起こりませんが、そのようなことはほとんどありません。
何か別の作業をしてから元のプロジェクトに戻ったとき、自分が何をしていたかを思い出すのは難しいですね(これは「コンテクスト・スイッチング」と呼ばれる現象です)。
標準化されたプロジェクト整理システムを使うことによって、混乱や時間のロスを減らすことができます。 つまり、再現性を高めているのです!
By using projects, it makes it straightforward to re-orient yourself if you return to an analysis after time spent elsewhere.
This wouldn't be a problem if we only ever work on one thing at a time until completion, but that is almost never the case.
It is hard to remember what you were doing when you come back to a project after working on something else (a phenomenon called "context switching").
By using a standardized organization system, you will reduce confusion and lost time... in other words, you are increasing reproducibility!

このワークショップではRStudioを使用します。RStudioは「プロジェクト」の概念と相性が良いからです。
This workshop will use RStudio, since it also works well with the project organization concept.

### RStudio でプロジェクトを作成する
### Create a project in RStudio

RStudioを使って新しいプロジェクトを開始しましょう。
Let's start a new project using RStudio.

"File" をクリックし、"New Project" を選択します。
Click "File", then select "New Project".

これにより、新規プロジェクトウィザードが開き、プロジェクトの設定に役立つメニューが表示されます。
This will open the New Project Wizard, a set of menus to help you set up the project.

![The New Project Wizard](fig/basic-rstudio-wizard.png){alt="Screenshot of RStudio New Project Wizard menu"}

ウィザードでは、ゼロから新しいプロジェクトを作るので、最初のオプション「新規ディレクトリ」をクリックします。
In the Wizard, click the first option, "New Directory", since we are making a brand-new project from scratch.
Click "New Project" in the next menu.
In "Directory name", enter a name that helps you remember the purpose of the project, such as "targets-demo" (follow best practices for naming files and folders).
Under "Create project as a subdirectory of...", click the "Browse" button to select a directory to put the project.
Expand Down Expand Up @@ -185,7 +185,7 @@ We see the raw data has some awkward column names with spaces (these are hard to
For the purposes of this analysis, we only need species name, bill length, and bill depth.
In the raw data, the rather technical term "culmen" is used to refer to the bill.

![Illustration of bill (culmen) length and depth. Artwork by @allison\_horst.](https://allisonhorst.github.io/palmerpenguins/reference/figures/culmen_depth.png)
![Illustration of bill (culmen) length and depth. Artwork by @allison_horst.](https://allisonhorst.github.io/palmerpenguins/reference/figures/culmen_depth.png)

Let's clean up the data to make it easier to use for downstream analyses.
We will also remove any rows with missing data, because this could cause errors for some functions later.
Expand Down Expand Up @@ -279,15 +279,15 @@ tar_make()
• start target penguins_csv_file
• built target penguins_csv_file [0.002 seconds]
• start target penguins_data_raw
• built target penguins_data_raw [0.101 seconds]
• built target penguins_data_raw [0.103 seconds]
• start target penguins_data
• built target penguins_data [0.012 seconds]
• end pipeline [0.315 seconds]
• end pipeline [0.325 seconds]
```

Congratulations, you've run your first workflow with `targets`!

::::::::::::::::::::::::::::::::::::: keypoints
::::::::::::::::::::::::::::::::::::: keypoints

- Projects help keep our analyses organized so we can easily re-run them later
- Use the RStudio Project Wizard to create projects
Expand Down
30 changes: 15 additions & 15 deletions branch.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Branching
title: 'Branching'
teaching: 10
exercises: 2
---

:::::::::::::::::::::::::::::::::::::: questions
:::::::::::::::::::::::::::::::::::::: questions

- How can we specify many targets without typing everything out?

Expand Down Expand Up @@ -81,8 +81,8 @@ tar_plan(
✔ skip target penguins_data_raw
✔ skip target penguins_data
• start target combined_model
• built target combined_model [0.03 seconds]
• end pipeline [0.131 seconds]
• built target combined_model [0.029 seconds]
• end pipeline [0.132 seconds]
```

Let's have a look at the model. We will use the `glance()` function from the `broom` package. Unlike base R `summary()`, this function returns output as a tibble (the tidyverse equivalent of a dataframe), which as we will see later is quite useful for downstream analyses.
Expand All @@ -101,7 +101,7 @@ glance(combined_model)
1 0.0552 0.0525 1.92 19.9 0.0000112 1 -708. 1422. 1433. 1256. 340 342
```

Notice the small _P_-value.
Notice the small *P*-value.
This seems to indicate that the model is highly significant.

But wait a moment... is this really an appropriate model? Recall that there are three species of penguins in the dataset. It is possible that the relationship between bill depth and length **varies by species**.
Expand Down Expand Up @@ -158,10 +158,10 @@ tar_plan(
• start target combined_summary
• built target combined_summary [0.009 seconds]
• start target interaction_summary
• built target interaction_summary [0.003 seconds]
• built target interaction_summary [0.004 seconds]
• start target species_summary
• built target species_summary [0.003 seconds]
• end pipeline [0.146 seconds]
• built target species_summary [0.004 seconds]
• end pipeline [0.145 seconds]
```

Let's look at the summary of one of the models:
Expand Down Expand Up @@ -234,11 +234,11 @@ First, let's look at the messages provided by `tar_make()`.
• start branch model_summaries_5ad4cec5
• built branch model_summaries_5ad4cec5 [0.008 seconds]
• start branch model_summaries_c73912d5
• built branch model_summaries_c73912d5 [0.003 seconds]
• built branch model_summaries_c73912d5 [0.004 seconds]
• start branch model_summaries_91696941
• built branch model_summaries_91696941 [0.003 seconds]
• built branch model_summaries_91696941 [0.004 seconds]
• built pattern model_summaries
• end pipeline [0.151 seconds]
• end pipeline [0.15 seconds]
```

There is a series of smaller targets (branches) that are each named like model_summaries_5ad4cec5, then one overall `model_summaries` target.
Expand Down Expand Up @@ -373,9 +373,9 @@ tar_plan(
• start branch model_summaries_c73912d5
• built branch model_summaries_c73912d5 [0.007 seconds]
• start branch model_summaries_91696941
• built branch model_summaries_91696941 [0.015 seconds]
• built branch model_summaries_91696941 [0.014 seconds]
• built pattern model_summaries
• end pipeline [0.182 seconds]
• end pipeline [0.171 seconds]
```

And this time, when we load the `model_summaries`, we can tell which model corresponds to which row (you may need to scroll to the right to see it).
Expand Down Expand Up @@ -516,9 +516,9 @@ You can [find out more about different branching patterns in the `targets` manua

:::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: keypoints
::::::::::::::::::::::::::::::::::::: keypoints

- Dynamic branching creates multiple targets with a single command
- You usually need to write custom functions so that the output of the branches includes necessary metadata
- You usually need to write custom functions so that the output of the branches includes necessary metadata

::::::::::::::::::::::::::::::::::::::::::::::::
19 changes: 9 additions & 10 deletions cache.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: Loading Workflow Objects
title: 'Loading Workflow Objects'
teaching: 10
exercises: 2
---



:::::::::::::::::::::::::::::::::::::: questions
:::::::::::::::::::::::::::::::::::::: questions

- ワークフローはどこで行われるのか?
- ワークフローによって構築されたオブジェクトを確認するには?
- Where does the workflow happen?
- How can we inspect the objects built by the workflow?

::::::::::::::::::::::::::::::::::::::::::::::::

Expand All @@ -26,13 +26,12 @@ Episode summary: Show how to get at the objects that we built

:::::::::::::::::::::::::::::::::::::

## ワークフローはどこで行われるのか?
## Where does the workflow happen?

So we just finished running our first workflow.
Now you probably want to look at its output.
But, if we just call the name of the object (for example, `penguins_data`), we get an error.


```r
penguins_data
```
Expand All @@ -55,7 +54,7 @@ This is for reproducibility---the objects built by the workflow should only depe
Fortunately, `targets` has two functions that can be used to load objects built by the workflow into our current session, `tar_load()` and `tar_read()`.
Let's see how these work.

## tar\_load()
## tar_load()

`tar_load()` loads an object built by the workflow into the current session.
Its first argument is the name of the object you want to load.
Expand All @@ -79,10 +78,10 @@ summary(penguins_data)
Max. :59.60 Max. :21.50
```

`tar_load()`は、その**副作用**、つまり、目的のオブジェクトを現在のRセッションにロードするために使用されることに注意してください。
Note that `tar_load()` is used for its **side-effect**---loading the desired object into the current R session.
It doesn't actually return a value.

## tar\_read()
## tar_read()

`tar_read()` is similar to `tar_load()` in that it is used to retrieve objects built by the workflow, but unlike `tar_load()`, it returns them directly as output.

Expand Down Expand Up @@ -136,7 +135,7 @@ Generally, `_targets/user` is a good place to store files that are not code, lik

Note that if you don't have anything in `_targets/user` that you need to keep around, it is possible to "reset" your workflow by simply deleting the entire `_targets` folder. Of course, this means you will need to run everything over again, so don't do this lightly!

::::::::::::::::::::::::::::::::::::: keypoints
::::::::::::::::::::::::::::::::::::: keypoints

- `targets` workflows are run in a separate, non-interactive R session
- `tar_load()` loads a workflow object into the current R session
Expand Down
Loading

0 comments on commit d3da837

Please sign in to comment.