Skip to content

Commit

Permalink
Small fixes.
Browse files Browse the repository at this point in the history
*  Fix link to best practices lesson.
*  Update exercise solution in instructor's guide
  • Loading branch information
jdblischak committed May 15, 2015
1 parent 7c7ad24 commit 0b708e8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2 id="topics">Topics</h2>
<li><a href="03-loops-R.html">Analyzing multiple data sets</a></li>
<li><a href="04-cond.html">Making choices</a></li>
<li><a href="05-cmdline.html">Command-Line Programs</a></li>
<li><a href="06-best-practices.html">Best practices for using R and designing programs</a></li>
<li><a href="06-best-practices-R.html">Best practices for using R and designing programs</a></li>
<li><a href="07-knitr-R.html">Dynamic reports with knitr</a></li>
<li><a href="08-making-packages-R.html">Making packages in R</a></li>
</ol>
Expand Down
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ and to use that language *well*.
3. [Analyzing multiple data sets](03-loops-R.html)
4. [Making choices](04-cond.html)
5. [Command-Line Programs](05-cmdline.html)
6. [Best practices for using R and designing programs](06-best-practices.html)
6. [Best practices for using R and designing programs](06-best-practices-R.html)
7. [Dynamic reports with knitr](07-knitr-R.html)
8. [Making packages in R](08-making-packages-R.html)

Expand Down
14 changes: 7 additions & 7 deletions instructors.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ An additional half-day could add the next two lessons:

Time-permitting, you can fit in one of these shorter lessons that cover bigger picture ideas like best practices for organizing code, reproducible research, and creating packages:

6. [Best practices for using R and designing programs](06-best-practices.html)
6. [Best practices for using R and designing programs](06-best-practices-R.html)
7. [Dynamic reports with knitr](07-knitr-R.html)
8. [Making packages in R](08-making-packages-R.html)

Expand All @@ -85,13 +85,13 @@ Time-permitting, you can fit in one of these shorter lessons that cover bigger p

```{r}
dat <- read.csv("data/inflammation-01.csv", header = FALSE)
element <- c("o", "x", "y", "g", "e", "n")
animal <- c("m", "o", "n", "k", "e", "y")
# Challenge - Slicing (subsetting data)
element[4:1] # first 4 characters in reverse order
element[-1] # remove first character
element[-4] # remove fourth character
element[-1:-4] # remove firts to fourth characters
element[c(5, 1, 6)] # new character vector
animal[4:1] # first 4 characters in reverse order
animal[-1] # remove first character
animal[-4] # remove fourth character
animal[-1:-4] # remove first to fourth characters
animal[c(5, 2, 3)] # new character vector
# Challenge - Subsetting data
max(dat[5, 3:7])
```
Expand Down
22 changes: 11 additions & 11 deletions instructors.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2 id="overall">Overall</h2>
</ol>
<p>Time-permitting, you can fit in one of these shorter lessons that cover bigger picture ideas like best practices for organizing code, reproducible research, and creating packages:</p>
<ol start="6" style="list-style-type: decimal">
<li><a href="06-best-practices.html">Best practices for using R and designing programs</a></li>
<li><a href="06-best-practices-R.html">Best practices for using R and designing programs</a></li>
<li><a href="07-knitr-R.html">Dynamic reports with knitr</a></li>
<li><a href="08-making-packages-R.html">Making packages in R</a></li>
</ol>
Expand All @@ -58,21 +58,21 @@ <h2 id="analyzing-patient-data"><a href="01-starting-with-data.html">Analyzing P
<li><p>Provide shortcut for the assignment operator (<code>&lt;-</code>) (RStudio: Alt+- on Windows/Linux; Option+- on Mac)</p></li>
</ul>
<pre class="sourceCode r"><code class="sourceCode r">dat &lt;-<span class="st"> </span><span class="kw">read.csv</span>(<span class="st">&quot;data/inflammation-01.csv&quot;</span>, <span class="dt">header =</span> <span class="ot">FALSE</span>)
element &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;o&quot;</span>, <span class="st">&quot;x&quot;</span>, <span class="st">&quot;y&quot;</span>, <span class="st">&quot;g&quot;</span>, <span class="st">&quot;e&quot;</span>, <span class="st">&quot;n&quot;</span>)
animal &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;m&quot;</span>, <span class="st">&quot;o&quot;</span>, <span class="st">&quot;n&quot;</span>, <span class="st">&quot;k&quot;</span>, <span class="st">&quot;e&quot;</span>, <span class="st">&quot;y&quot;</span>)
<span class="co"># Challenge - Slicing (subsetting data)</span>
element[<span class="dv">4</span>:<span class="dv">1</span>] <span class="co"># first 4 characters in reverse order</span></code></pre>
<pre class="output"><code>[1] &quot;g&quot; &quot;y&quot; &quot;x&quot; &quot;o&quot;
animal[<span class="dv">4</span>:<span class="dv">1</span>] <span class="co"># first 4 characters in reverse order</span></code></pre>
<pre class="output"><code>[1] &quot;k&quot; &quot;n&quot; &quot;o&quot; &quot;m&quot;
</code></pre>
<pre class="sourceCode r"><code class="sourceCode r">element[-<span class="dv">1</span>] <span class="co"># remove first character</span></code></pre>
<pre class="output"><code>[1] &quot;x&quot; &quot;y&quot; &quot;g&quot; &quot;e&quot; &quot;n&quot;
<pre class="sourceCode r"><code class="sourceCode r">animal[-<span class="dv">1</span>] <span class="co"># remove first character</span></code></pre>
<pre class="output"><code>[1] &quot;o&quot; &quot;n&quot; &quot;k&quot; &quot;e&quot; &quot;y&quot;
</code></pre>
<pre class="sourceCode r"><code class="sourceCode r">element[-<span class="dv">4</span>] <span class="co"># remove fourth character</span></code></pre>
<pre class="output"><code>[1] &quot;o&quot; &quot;x&quot; &quot;y&quot; &quot;e&quot; &quot;n&quot;
<pre class="sourceCode r"><code class="sourceCode r">animal[-<span class="dv">4</span>] <span class="co"># remove fourth character</span></code></pre>
<pre class="output"><code>[1] &quot;m&quot; &quot;o&quot; &quot;n&quot; &quot;e&quot; &quot;y&quot;
</code></pre>
<pre class="sourceCode r"><code class="sourceCode r">element[-<span class="dv">1</span>:-<span class="dv">4</span>] <span class="co"># remove firts to fourth characters</span></code></pre>
<pre class="output"><code>[1] &quot;e&quot; &quot;n&quot;
<pre class="sourceCode r"><code class="sourceCode r">animal[-<span class="dv">1</span>:-<span class="dv">4</span>] <span class="co"># remove first to fourth characters</span></code></pre>
<pre class="output"><code>[1] &quot;e&quot; &quot;y&quot;
</code></pre>
<pre class="sourceCode r"><code class="sourceCode r">element[<span class="kw">c</span>(<span class="dv">5</span>, <span class="dv">1</span>, <span class="dv">6</span>)] <span class="co"># new character vector</span></code></pre>
<pre class="sourceCode r"><code class="sourceCode r">animal[<span class="kw">c</span>(<span class="dv">5</span>, <span class="dv">2</span>, <span class="dv">3</span>)] <span class="co"># new character vector</span></code></pre>
<pre class="output"><code>[1] &quot;e&quot; &quot;o&quot; &quot;n&quot;
</code></pre>
<pre class="sourceCode r"><code class="sourceCode r"><span class="co"># Challenge - Subsetting data</span>
Expand Down
22 changes: 11 additions & 11 deletions instructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ An additional half-day could add the next two lessons:

Time-permitting, you can fit in one of these shorter lessons that cover bigger picture ideas like best practices for organizing code, reproducible research, and creating packages:

6. [Best practices for using R and designing programs](06-best-practices.html)
6. [Best practices for using R and designing programs](06-best-practices-R.html)
7. [Dynamic reports with knitr](07-knitr-R.html)
8. [Making packages in R](08-making-packages-R.html)

Expand All @@ -84,61 +84,61 @@ Time-permitting, you can fit in one of these shorter lessons that cover bigger p

~~~{.r}
dat <- read.csv("data/inflammation-01.csv", header = FALSE)
element <- c("o", "x", "y", "g", "e", "n")
animal <- c("m", "o", "n", "k", "e", "y")
# Challenge - Slicing (subsetting data)
element[4:1] # first 4 characters in reverse order
animal[4:1] # first 4 characters in reverse order
~~~



~~~{.output}
[1] "g" "y" "x" "o"
[1] "k" "n" "o" "m"
~~~



~~~{.r}
element[-1] # remove first character
animal[-1] # remove first character
~~~



~~~{.output}
[1] "x" "y" "g" "e" "n"
[1] "o" "n" "k" "e" "y"
~~~



~~~{.r}
element[-4] # remove fourth character
animal[-4] # remove fourth character
~~~



~~~{.output}
[1] "o" "x" "y" "e" "n"
[1] "m" "o" "n" "e" "y"
~~~



~~~{.r}
element[-1:-4] # remove firts to fourth characters
animal[-1:-4] # remove first to fourth characters
~~~



~~~{.output}
[1] "e" "n"
[1] "e" "y"
~~~



~~~{.r}
element[c(5, 1, 6)] # new character vector
animal[c(5, 2, 3)] # new character vector
~~~


Expand Down

0 comments on commit 0b708e8

Please sign in to comment.