Skip to content

Commit

Permalink
update ch 4 walkthrough link
Browse files Browse the repository at this point in the history
  • Loading branch information
debruine committed May 7, 2024
1 parent 4a9e194 commit 70a7179
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions _freeze/04-summary/execute-results/html.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/04-summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ <h1 class="title"><span id="sec-summary" class="quarto-section-identifier"><span
</ul>
</li>
</ul></section><section id="sec-walkthrough-summary" class="level2 unnumbered"><h2 class="unnumbered anchored" data-anchor-id="sec-walkthrough-summary">Walkthrough video</h2>
<p>There is a walkthrough video of this chapter available via <a href="">Echo360</a>. Please note that there may have been minor edits to the book since the video was recorded. Where there are differences, the book should always take precedence.</p>
<p>There is a walkthrough video of this chapter available via <a href="https://echo360.org.uk/media/7684e5ec-5ca7-44e4-9a22-f46f21da498c/public">Echo360</a>. Please note that there may have been minor edits to the book since the video was recorded. Where there are differences, the book should always take precedence.</p>
</section><section id="sec-setup-summary" class="level2" data-number="4.2"><h2 data-number="4.2" class="anchored" data-anchor-id="sec-setup-summary">
<span class="header-section-number">4.2</span> Set-up</h2>
<p>First, create a new project for the work we’ll do in this chapter named <code class="path">04-summary</code>. Second, download the data for this chapter (<a href="data/12.1_delivery.csv" download="">12.1_delivery.csv</a>) and save it in your project data folder. Finally, open and save and new R Markdown document named <code>summary.Rmd</code>, delete the welcome text and load the required packages for this chapter.</p>
Expand Down Expand Up @@ -1073,8 +1073,8 @@ <h1 class="title"><span id="sec-summary" class="quarto-section-identifier"><span
</div>
</div>
</div>
<div id="radio_AHMCCCJGDJ" class="webex-radiogroup">
<label><input type="radio" autocomplete="off" name="radio_AHMCCCJGDJ" value="x"><span><code>count(induced, births, sort = TRUE)</code></span></label><label><input type="radio" autocomplete="off" name="radio_AHMCCCJGDJ" value="x"><span><code>count(births, induced)</code></span></label><label><input type="radio" autocomplete="off" name="radio_AHMCCCJGDJ" value="answer"><span><code>count(births, induced, sort = TRUE)</code></span></label><label><input type="radio" autocomplete="off" name="radio_AHMCCCJGDJ" value="x"><span><code>count(induced, births)</code></span></label>
<div id="radio_ORQBNFLHJI" class="webex-radiogroup">
<label><input type="radio" autocomplete="off" name="radio_ORQBNFLHJI" value="answer"><span><code>count(births, induced, sort = TRUE)</code></span></label><label><input type="radio" autocomplete="off" name="radio_ORQBNFLHJI" value="x"><span><code>count(induced, births)</code></span></label><label><input type="radio" autocomplete="off" name="radio_ORQBNFLHJI" value="x"><span><code>count(induced, births, sort = TRUE)</code></span></label><label><input type="radio" autocomplete="off" name="radio_ORQBNFLHJI" value="x"><span><code>count(births, induced)</code></span></label>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@
"href": "04-summary.html#counting",
"title": "4  Data Summaries",
"section": "\n4.5 Counting",
"text": "4.5 Counting\nYou can count categorical data with the count() function. This will give you a new table with each combination of the counted columns and a column called n containing the number of rows from that group.\nLet’s figure out how many entries there were per delivery type. The first argument is the name of the data table object, and the second argument is the name of the column we want to count.\n\ncount(births, delivery)\n\n\n\n\ndelivery\nn\n\n\n\nSpontaneous\n25607\n\n\nCaesarean - Emergency\n22526\n\n\nForceps\n19041\n\n\nVacuum\n14573\n\n\nCaesarean - Elective\n12417\n\n\nBreech\n2483\n\n\nNot Known\n430\n\n\n\n\n\n\nThere are 7 types of deliveries, and the new column n tells you how many rows of the data table there are per type.\nYou can add on a column with the numbers expressed in percent using the function mutate(). We’ll go into more detail on how to use mutate() in Chapter 9, but for now, it can be used to add new columns or overwrite existing columns.\nThe code below divides the value in the n column by the total sum of the numbers in that column, and adds it to a new column called percent. The next step modifies the percent column by multiplying it by 100 and rounding the value. You could do this all in one step, like round(100 * n / sum(n)), but often it’s clearer to break it into a few steps to avoid too many nested parentheses.\n\ncount(births, delivery) %&gt;%\n mutate(percent = n / sum(n),\n percent = round(100 * percent))\n\n\n\n\ndelivery\nn\npercent\n\n\n\nSpontaneous\n25607\n26\n\n\nCaesarean - Emergency\n22526\n23\n\n\nForceps\n19041\n20\n\n\nVacuum\n14573\n15\n\n\nCaesarean - Elective\n12417\n13\n\n\nBreech\n2483\n3\n\n\nNot Known\n430\n0\n\n\n\n\n\n\nWe can also count combinations of columns by adding more arguments. The table below shows the number of rows per age group and induction status, sorted by the number of rows. We won’t add on percent just yet as the additional variable requires another function that we’ll come back to later.\n\ncount(births, age_group, induced, sort = TRUE)\n\n\n\n\nage_group\ninduced\nn\n\n\n\n25-34\nNot Induced\n20441\n\n\n35 and over\nNot Induced\n16965\n\n\nUnder 25\nNot Induced\n16805\n\n\n25-34\nInduced\n15176\n\n\nUnder 25\nInduced\n12206\n\n\n35 and over\nInduced\n11711\n\n\n25-34\nUnknown\n1940\n\n\n35 and over\nUnknown\n916\n\n\nUnder 25\nUnknown\n907\n\n\nUnknown\nNot Induced\n6\n\n\nUnknown\nInduced\n4\n\n\n\n\n\n\n\n\n\n\n\n\nNote\n\n\n\nHow would you create the table of counts below?\n\n\n\n\n\ninduced\nn\n\n\n\nNot Induced\n54217\n\n\nInduced\n39097\n\n\nUnknown\n3763\n\n\n\n\n\n\n\ncount(induced, births, sort = TRUE)count(births, induced)count(births, induced, sort = TRUE)count(induced, births)\n\n\n\nHowever, the numbers above are not the number of births, but rather the number of rows in the data set. The column live_births contains the number per each category, so we will need to add those numbers together to see the total number of births.",
"text": "4.5 Counting\nYou can count categorical data with the count() function. This will give you a new table with each combination of the counted columns and a column called n containing the number of rows from that group.\nLet’s figure out how many entries there were per delivery type. The first argument is the name of the data table object, and the second argument is the name of the column we want to count.\n\ncount(births, delivery)\n\n\n\n\ndelivery\nn\n\n\n\nSpontaneous\n25607\n\n\nCaesarean - Emergency\n22526\n\n\nForceps\n19041\n\n\nVacuum\n14573\n\n\nCaesarean - Elective\n12417\n\n\nBreech\n2483\n\n\nNot Known\n430\n\n\n\n\n\n\nThere are 7 types of deliveries, and the new column n tells you how many rows of the data table there are per type.\nYou can add on a column with the numbers expressed in percent using the function mutate(). We’ll go into more detail on how to use mutate() in Chapter 9, but for now, it can be used to add new columns or overwrite existing columns.\nThe code below divides the value in the n column by the total sum of the numbers in that column, and adds it to a new column called percent. The next step modifies the percent column by multiplying it by 100 and rounding the value. You could do this all in one step, like round(100 * n / sum(n)), but often it’s clearer to break it into a few steps to avoid too many nested parentheses.\n\ncount(births, delivery) %&gt;%\n mutate(percent = n / sum(n),\n percent = round(100 * percent))\n\n\n\n\ndelivery\nn\npercent\n\n\n\nSpontaneous\n25607\n26\n\n\nCaesarean - Emergency\n22526\n23\n\n\nForceps\n19041\n20\n\n\nVacuum\n14573\n15\n\n\nCaesarean - Elective\n12417\n13\n\n\nBreech\n2483\n3\n\n\nNot Known\n430\n0\n\n\n\n\n\n\nWe can also count combinations of columns by adding more arguments. The table below shows the number of rows per age group and induction status, sorted by the number of rows. We won’t add on percent just yet as the additional variable requires another function that we’ll come back to later.\n\ncount(births, age_group, induced, sort = TRUE)\n\n\n\n\nage_group\ninduced\nn\n\n\n\n25-34\nNot Induced\n20441\n\n\n35 and over\nNot Induced\n16965\n\n\nUnder 25\nNot Induced\n16805\n\n\n25-34\nInduced\n15176\n\n\nUnder 25\nInduced\n12206\n\n\n35 and over\nInduced\n11711\n\n\n25-34\nUnknown\n1940\n\n\n35 and over\nUnknown\n916\n\n\nUnder 25\nUnknown\n907\n\n\nUnknown\nNot Induced\n6\n\n\nUnknown\nInduced\n4\n\n\n\n\n\n\n\n\n\n\n\n\nNote\n\n\n\nHow would you create the table of counts below?\n\n\n\n\n\ninduced\nn\n\n\n\nNot Induced\n54217\n\n\nInduced\n39097\n\n\nUnknown\n3763\n\n\n\n\n\n\n\ncount(births, induced, sort = TRUE)count(induced, births)count(induced, births, sort = TRUE)count(births, induced)\n\n\n\nHowever, the numbers above are not the number of births, but rather the number of rows in the data set. The column live_births contains the number per each category, so we will need to add those numbers together to see the total number of births.",
"crumbs": [
"<span class='chapter-number'>4</span>  <span class='chapter-title'>Data Summaries</span>"
]
Expand Down

0 comments on commit 70a7179

Please sign in to comment.