Skip to content

Commit

Permalink
Render toc-less
Browse files Browse the repository at this point in the history
  • Loading branch information
jhudsl-robot committed Oct 10, 2023
1 parent 6c73c2a commit 2ae7f20
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions docs/no_toc/02-lesson2.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ Let's convert this into code!

```r
metadata_filtered = filter(metadata, OncotreeLineage == "Breast")
brca_metadata = select(metadata_filtered, ModelID, Age, Sex)
head(brca_metadata)
breast_metadata = select(metadata_filtered, ModelID, Age, Sex)
head(breast_metadata)
```

```
Expand All @@ -392,7 +392,7 @@ Let's carefully a look what how the R Console is interpreting the `filter()` fun

- The first argument of `filter()` is a dataframe, which we give `metadata`.

- The second argument is strange: the expression we give it looks like a logical indexing vector built from a comparison operator, but the variable `OncotreeLineage` does not exist in our environment! Rather, `OncotreeLineage` is a column from `metadata`, and we are referring to it as a **data variable** in the context of the dataframe `metadata`. So, we make a comparsion operation on the column `OncotreeLineage` from `metadata` and its resulting logical indexing vector is the input to the second argument.
- The second argument is strange: the expression we give it looks like a logical indexing vector built from a comparison operator, but the variable `OncotreeLineage` does not exist in our environment! Rather, `OncotreeLineage` is a column from `metadata`, and we are referring to it as a **data variable** in the context of the dataframe `metadata`. So, we make a comparison operation on the column `OncotreeLineage` from `metadata` and its resulting logical indexing vector is the input to the second argument.

- How do we know when a variable being used is a variable from the environment, or a data variable from a dataframe? It's not clear cut, but here's a rule of thumb: most functions from the `tidyverse` package allows you to use data variables to refer to columns of a dataframe. We refer to documentation when we are not sure.

Expand All @@ -416,4 +416,4 @@ Let's carefully a look what how the R Console is interpreting the `select()` fun

- Putting it together, `select()` takes in a dataframe, and as many data variables you like to select columns, and returns a dataframe with the columns you described by data variables.

- Store this in `brca_metadata` variable.
- Store this in `breast_metadata` variable.
2 changes: 1 addition & 1 deletion docs/no_toc/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ These credits are based on our [course contributors table guidelines](https://ww
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-10-06
## date 2023-10-10
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
2 changes: 1 addition & 1 deletion docs/no_toc/about-the-authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ <h1>About the Authors</h1>
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-10-06
## date 2023-10-10
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
2 changes: 1 addition & 1 deletion docs/no_toc/search_index.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/no_toc/working-with-data-structures.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ <h3><span class="header-section-number">3.2.2</span> “What do you want to do w
<p>(This is because we are guaranteed to have column names in dataframes. Some dataframes have row names, but because the data types are not guranteed to have the same data type, it makes describing by row properties difficult.)</p>
<p>Let’s convert this into code!</p>
<div class="sourceCode" id="cb74"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb74-1"><a href="working-with-data-structures.html#cb74-1" aria-hidden="true" tabindex="-1"></a>metadata_filtered <span class="ot">=</span> <span class="fu">filter</span>(metadata, OncotreeLineage <span class="sc">==</span> <span class="st">&quot;Breast&quot;</span>)</span>
<span id="cb74-2"><a href="working-with-data-structures.html#cb74-2" aria-hidden="true" tabindex="-1"></a>brca_metadata <span class="ot">=</span> <span class="fu">select</span>(metadata_filtered, ModelID, Age, Sex)</span>
<span id="cb74-3"><a href="working-with-data-structures.html#cb74-3" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(brca_metadata)</span></code></pre></div>
<span id="cb74-2"><a href="working-with-data-structures.html#cb74-2" aria-hidden="true" tabindex="-1"></a>breast_metadata <span class="ot">=</span> <span class="fu">select</span>(metadata_filtered, ModelID, Age, Sex)</span>
<span id="cb74-3"><a href="working-with-data-structures.html#cb74-3" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(breast_metadata)</span></code></pre></div>
<pre><code>## ModelID Age Sex
## 1 ACH-000017 43 Female
## 2 ACH-000019 69 Female
Expand All @@ -401,7 +401,7 @@ <h3><span class="header-section-number">3.2.3</span> Filter rows</h3>
<ul>
<li><p>We evaluate the expression right of <code>=</code>.</p></li>
<li><p>The first argument of <code>filter()</code> is a dataframe, which we give <code>metadata</code>.</p></li>
<li><p>The second argument is strange: the expression we give it looks like a logical indexing vector built from a comparison operator, but the variable <code>OncotreeLineage</code> does not exist in our environment! Rather, <code>OncotreeLineage</code> is a column from <code>metadata</code>, and we are referring to it as a <strong>data variable</strong> in the context of the dataframe <code>metadata</code>. So, we make a comparsion operation on the column <code>OncotreeLineage</code> from <code>metadata</code> and its resulting logical indexing vector is the input to the second argument.</p>
<li><p>The second argument is strange: the expression we give it looks like a logical indexing vector built from a comparison operator, but the variable <code>OncotreeLineage</code> does not exist in our environment! Rather, <code>OncotreeLineage</code> is a column from <code>metadata</code>, and we are referring to it as a <strong>data variable</strong> in the context of the dataframe <code>metadata</code>. So, we make a comparison operation on the column <code>OncotreeLineage</code> from <code>metadata</code> and its resulting logical indexing vector is the input to the second argument.</p>
<ul>
<li><p>How do we know when a variable being used is a variable from the environment, or a data variable from a dataframe? It’s not clear cut, but here’s a rule of thumb: most functions from the <code>tidyverse</code> package allows you to use data variables to refer to columns of a dataframe. We refer to documentation when we are not sure.</p></li>
<li><p>This encourages more <em>readable</em> code at the expense of consistency of referring to variables in the environment. The authors of this package <a href="https://dplyr.tidyverse.org/articles/programming.html#data--and-env-variables">describes this trade-off</a>.</p></li>
Expand All @@ -421,7 +421,7 @@ <h3><span class="header-section-number">3.2.4</span> Select columns</h3>
<li>For certain functions like <code>filter()</code>, there is no limit on the number of arguments you provide. You can keep adding data variables to select for more column names.</li>
</ul></li>
<li><p>Putting it together, <code>select()</code> takes in a dataframe, and as many data variables you like to select columns, and returns a dataframe with the columns you described by data variables.</p></li>
<li><p>Store this in <code>brca_metadata</code> variable.</p></li>
<li><p>Store this in <code>breast_metadata</code> variable.</p></li>
</ul>

</div>
Expand Down

0 comments on commit 2ae7f20

Please sign in to comment.