Skip to content

Commit

Permalink
updated reshape0
Browse files Browse the repository at this point in the history
  • Loading branch information
rmonajemi committed Oct 8, 2021
1 parent ed9b3a5 commit de4434a
Show file tree
Hide file tree
Showing 31 changed files with 432 additions and 514 deletions.
6 changes: 6 additions & 0 deletions R/Doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ BaseRenderer <- R6Class(
id2url = function( id ) stop( "Not inherited." ),
makeAll = function( course, makeZip = TRUE, ... ) {
self$clearDir()
# Copy rcourse/{footer.html,fold.html,styles.css} to self$outDir(). This to
# avoid relative path issue in _site.yml whene render is called on default
# .doc or docs/<course-name>.
# make a list of files to be copied in the config.yml
file.copy(file.path(course$dir(), c("footer.html","fold.html","styles.css")), self$outDir())
#
allFiles <- c(
self$makeLectures( course, ... ),
self$makeTasks( course, enableCode = FALSE, ... ),
Expand Down
61 changes: 8 additions & 53 deletions docs/Boerhaave_202110/S00L01c_toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ <h2>Contents</h2>
<a class="btn btn-primary" href="S02L04s_basic_factors0.tasks.code.html" role="button">Solutions</a>
</td>
</tr>
<tr grouplength="8">
<tr grouplength="6">
<td colspan="5" style="border-bottom: 1px solid;">
<strong>Data manipulation 1/3 (Wednesday, Oct 13, 09:00-12:30)</strong>
</td>
Expand Down Expand Up @@ -616,24 +616,10 @@ <h2>Contents</h2>
</tr>
<tr>
<td style="text-align:left; padding-left: 2em;" indentlevel="1">
― <em>break</em> ―
</td>
<td style="text-align:left;">
10:00-10:15
</td>
<td style="text-align:left;">
</td>
<td style="text-align:left;">
</td>
<td style="text-align:left;">
</td>
</tr>
<tr>
<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Select variables/cols
</td>
<td style="text-align:left;">
10:15-11:00
10:00-10:45
</td>
<td style="text-align:left;">
<a class="btn btn-primary" href="S03L03l_dplyr_select0.html" role="button">Lecture</a>
Expand All @@ -647,27 +633,10 @@ <h2>Contents</h2>
</tr>
<tr>
<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Filter observations/rows
</td>
<td style="text-align:left;">
11:00-11:15
</td>
<td style="text-align:left;">
<a class="btn btn-primary" href="S03L04l_dplyr_filter0.html" role="button">Lecture</a>
</td>
<td style="text-align:left;">
<a class="btn btn-primary" href="S03L04p_dplyr_filter0.tasks.nocode.html" role="button">Practice</a>
</td>
<td style="text-align:left;">
<a class="btn btn-primary" href="S03L04s_dplyr_filter0.tasks.code.html" role="button">Solutions</a>
</td>
</tr>
<tr>
<td style="text-align:left; padding-left: 2em;" indentlevel="1">
― <em>break</em> ―
</td>
<td style="text-align:left;">
11:15-11:30
10:45-11:00
</td>
<td style="text-align:left;">
</td>
Expand All @@ -681,7 +650,7 @@ <h2>Contents</h2>
Filter observations/rows
</td>
<td style="text-align:left;">
11:30-12:00
11:00-11:45
</td>
<td style="text-align:left;">
<a class="btn btn-primary" href="S03L04l_dplyr_filter0.html" role="button">Lecture</a>
Expand All @@ -698,7 +667,7 @@ <h2>Contents</h2>
Add/modify variables
</td>
<td style="text-align:left;">
12:00-12:30
11:45-12:30
</td>
<td style="text-align:left;">
<a class="btn btn-primary" href="S03L05l_dplyr_mutate0.html" role="button">Lecture</a>
Expand Down Expand Up @@ -991,17 +960,17 @@ <h2>Contents</h2>
<td style="text-align:left;">
</td>
</tr>
<tr grouplength="7">
<tr grouplength="6">
<td colspan="5" style="border-bottom: 1px solid;">
<strong>Data manipulation 3/3 and functions (Friday, Oct 15, 09:00-12:30)</strong>
</td>
</tr>
<tr>
<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Merging/joining tables
Joining tables
</td>
<td style="text-align:left;">
09:00-09:45
09:00-10:00
</td>
<td style="text-align:left;">
<a class="btn btn-primary" href="S07L01l_dplyr_join0.html" role="button">Lecture</a>
Expand All @@ -1015,20 +984,6 @@ <h2>Contents</h2>
</tr>
<tr>
<td style="text-align:left; padding-left: 2em;" indentlevel="1">
― <em>break</em> ―
</td>
<td style="text-align:left;">
09:45-10:00
</td>
<td style="text-align:left;">
</td>
<td style="text-align:left;">
</td>
<td style="text-align:left;">
</td>
</tr>
<tr>
<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Reshaping tables
</td>
<td style="text-align:left;">
Expand Down
56 changes: 28 additions & 28 deletions docs/Boerhaave_202110/S02L01s_basic_vectors0.tasks.code.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,48 +390,48 @@ <h2>Primary exercises</h2>
</ol>
<pre class="r"><code>v &lt;- rnorm( 10 ) # a vector of random numbers
v</code></pre>
<pre><code> [1] -1.62291325 0.95847246 0.08196443 0.54409205 1.13142631 -0.50743260 0.25513347 0.20318319
[9] 0.97402405 0.38997078</code></pre>
<pre><code> [1] 0.7937472 -1.0087640 -1.3903875 -0.4187800 -1.3761140 0.1322108 -0.5739516 -1.3789547 -0.0075223
[10] -0.8189675</code></pre>
<pre class="r"><code>v &lt;- rnorm( 10 ) # another vector of random numbers
v</code></pre>
<pre><code> [1] 1.2902434 -0.7014971 1.5156270 -0.3275760 -1.3415029 1.8590176 0.6984202 -1.0443753 2.3604989
[10] -1.1413431</code></pre>
<pre><code> [1] -1.2473570 1.3865308 -0.1580330 -0.6584027 0.1566449 0.3764169 -0.4764282 1.2185440 1.4531192
[10] 0.3159742</code></pre>
<pre class="r"><code>min( v )</code></pre>
<pre><code>[1] -1.341503</code></pre>
<pre><code>[1] -1.247357</code></pre>
<pre class="r"><code>max( v )</code></pre>
<pre><code>[1] 2.360499</code></pre>
<pre><code>[1] 1.453119</code></pre>
<pre class="r"><code>mean( v )</code></pre>
<pre><code>[1] 0.3167513</code></pre>
<pre><code>[1] 0.2367009</code></pre>
<pre class="r"><code>median( v )</code></pre>
<pre><code>[1] 0.1854221</code></pre>
<pre><code>[1] 0.2363095</code></pre>
<pre class="r"><code>sd( v )</code></pre>
<pre><code>[1] 1.385105</code></pre>
<pre><code>[1] 0.9108005</code></pre>
<ol start="6" style="list-style-type: decimal">
<li><em>Selecting and counting elements by a condition</em>. Type <code>v &lt; 0</code> and understand the result.<br />
How to interpret the number produced by <code>sum( v &lt; 0 )</code>? How to interpret the number produced by <code>sum( !( v &lt; 0 ) )</code>?</li>
</ol>
<pre class="r"><code>v &lt; 0 # TRUE corresponds to elements of vector v smaller than 0</code></pre>
<pre><code> [1] FALSE TRUE FALSE TRUE TRUE FALSE FALSE TRUE FALSE TRUE</code></pre>
<pre><code> [1] TRUE FALSE TRUE TRUE FALSE FALSE TRUE FALSE FALSE FALSE</code></pre>
<pre class="r"><code>sum( v &lt; 0 ) # calculates the number of negative elements in vector v</code></pre>
<pre><code>[1] 5</code></pre>
<pre><code>[1] 4</code></pre>
<pre class="r"><code>sum( !( v &lt; 0 ) ) # calculates the number of non-negative (so, positive OR ZERO) elements in vector v </code></pre>
<pre><code>[1] 5</code></pre>
<pre><code>[1] 6</code></pre>
<pre class="r"><code>sum( v &gt;= 0 ) # same as above</code></pre>
<pre><code>[1] 5</code></pre>
<pre><code>[1] 6</code></pre>
<ol start="7" style="list-style-type: decimal">
<li><em>Head and tail</em>.<br />
Often there is a need to quickly look at the beginning (<code>head</code>) or at the end (<code>tail</code>) of a vector.<br />
Try these functions to show the first 5 and the last 7 elements of a randomly generated vector <code>v &lt;- rnorm( 20 )</code>.</li>
</ol>
<pre class="r"><code>v &lt;- rnorm( 20 )
v</code></pre>
<pre><code> [1] 0.46891296 -0.46498371 -1.01569568 0.08983452 1.89631016 -0.90828665 1.82875359 -1.35528564
[9] -0.32686536 -0.77723603 1.94866475 -0.74793928 0.30711259 0.16227810 -0.18126833 0.77305165
[17] 0.31382362 0.86717220 0.01348908 -1.68611814</code></pre>
<pre><code> [1] 0.49168494 -0.71588185 -2.29895757 -0.92007654 -1.44030517 0.07771069 -0.48200707 0.60780228
[9] -0.20809487 -1.52883530 1.03345287 -0.65104507 0.38363254 0.76943290 0.41423687 1.96510485
[17] -0.71668923 0.46486082 1.82292165 -0.38959121</code></pre>
<pre class="r"><code>head( v, 5 )</code></pre>
<pre><code>[1] 0.46891296 -0.46498371 -1.01569568 0.08983452 1.89631016</code></pre>
<pre><code>[1] 0.4916849 -0.7158818 -2.2989576 -0.9200765 -1.4403052</code></pre>
<pre class="r"><code>tail( v, 7 )</code></pre>
<pre><code>[1] 0.16227810 -0.18126833 0.77305165 0.31382362 0.86717220 0.01348908 -1.68611814</code></pre>
<pre><code>[1] 0.7694329 0.4142369 1.9651048 -0.7166892 0.4648608 1.8229216 -0.3895912</code></pre>
</div>
<div id="extra-exercises" class="section level2">
<h2>Extra exercises</h2>
Expand Down Expand Up @@ -535,18 +535,18 @@ <h2>Extra exercises</h2>
<pre class="r"><code>fileName &lt;- &quot;test.txt&quot;
v &lt;- sample( 1:100, 10 )
v</code></pre>
<pre><code> [1] 52 49 93 78 38 23 45 11 48 62</code></pre>
<pre><code> [1] 90 25 41 86 69 45 26 38 1 65</code></pre>
<pre class="r"><code>writeLines( as.character( v ) ) # conversion to character needed</code></pre>
<pre><code>52
49
93
78
38
23
<pre><code>90
25
41
86
69
45
11
48
62</code></pre>
26
38
1
65</code></pre>
<pre class="r"><code>writeLines( as.character( v ), con = fileName )
w &lt;- readLines( con = fileName )
identical( v, w ) # numbers are not the same as their text representation</code></pre>
Expand Down
Loading

0 comments on commit de4434a

Please sign in to comment.