Skip to content
Snippets Groups Projects
Commit 9953af68 authored by hpolvech's avatar hpolvech
Browse files

HTML_tuto: terminated

parent 656d8814
Branches
No related tags found
No related merge requests found
...@@ -12,6 +12,10 @@ h3 { /* Header 3 */ ...@@ -12,6 +12,10 @@ h3 { /* Header 3 */
color: #729FCF ; color: #729FCF ;
left: 5%; left: 5%;
} }
h2 { /* Header 2 */
color: darkblue ;
left: 10%;
}
h1 { /* Header 1 */ h1 { /* Header 1 */
color: #034b6f ; color: #034b6f ;
} }
...@@ -207,7 +211,7 @@ Compute the factorial of 9 (`9!`) ...@@ -207,7 +211,7 @@ Compute the factorial of 9 (`9!`)
``` ```
\ \
**or** or
```{r calculatorstep12, include=TRUE} ```{r calculatorstep12, include=TRUE}
factorial(9) factorial(9)
``` ```
...@@ -390,8 +394,7 @@ This block allows you to view the different outputs (?help, graphs, etc.). ...@@ -390,8 +394,7 @@ This block allows you to view the different outputs (?help, graphs, etc.).
![](./img/formationR_VandAstep8_encadre.png) ![](./img/formationR_VandAstep8_encadre.png)
\
### Functions are also variables
Test that your `logarithm` function can work in base 10 Test that your `logarithm` function can work in base 10
...@@ -518,116 +521,158 @@ ls() ...@@ -518,116 +521,158 @@ ls()
\ \
# Packages <fieldset id='pencadre' style='text-align: left'>
## Installing packages <legend style='border: 0px;'>Summary box</legend>
<li> Assigning a variable is done with ` <- `.</li>
<li> The assigned variables are listed in the environment box.</li>
<li> Variable names can contain letters, numbers, underscores and periods. </li>
<li> Functions are also variable and can write in several forms</li>
<li> An editing box is available on Rstudio.</li>
```R </fieldset>
install.packages("tidyverse")
```
```R \
install.packages("ggplot2")
```
## Loading packages \
```{r packagesstep1, include=TRUE} # Complex variable type
sessionInfo()
```
\ ### Vector (aka list)
```{r packagesstep2, include=TRUE} ```{r Vecstep1, include=TRUE}
library(tidyverse) c(1, 2, 3, 4, 5)
``` ```
or
```R ```{r Vecstep2, include=TRUE}
sessionInfo() c(1:5)
``` ```
\ \
```{r packagesstep4, include=TRUE} \
unloadNamespace("tidyverse") A mathematical calculation can be performed on the elements of the vector:
```{r Vecstep3, include=TRUE}
2^(1:5)
``` ```
```R ```{r Vecstep4, include=TRUE}
sessionInfo() x <- 1:5
2^x
``` ```
\ \
# Complex variable type \
To determine the type of the elements of a vector:
## Vector (aka list) ```{r Vecstep5, include=TRUE}
typeof(x)
```
```R
c(1, 2, 3, 4, 5) ```{r Vecstep6, include=TRUE}
typeof(x + 0.5)
x + 0.5
``` ```
\pause
```R ```{r Vecstep7, include=TRUE}
1:5 is.vector(x)
``` ```
\pause \
```R \
2^(1:5)
```{r Vecstep8, include=TRUE}
y <- c(a = 1, b = 2, c = 3, d = 4, e = 5)
typeof(y)
is.vector(y)
``` ```
\pause \
```R \
x <- 1:5 We can compare the elements of two vectors:
2^x
```{r Vecstep9, include=TRUE}
x
y
x == y
``` ```
\pause \
```R \
log(x)
logarithm(x) If you use `all.equal` :
base_test(x, base = 10)
```{r Vecstep10, include=TRUE}
all.equal(x, y)
isTRUE(all.equal(x, y))
isTRUE(all.equal(x, y, check.attributes = FALSE))
``` ```
\
<fieldset id='pencadre' style='text-align: left'>
<legend style='border: 0px;'>Summary box</legend>
<li> A variable can be of different types : `numeric`, `character`, `vector`, etc.</li>
<li> Calculations and comparisons apply to vectors.</li>
<li> Do not hesitate to use the help box to understand functions! </li>
</fieldset>
\
## Vector (aka list) \
# Packages
### Installing packages
```R ```R
typeof(x) install.packages("tidyverse")
``` ```
\pause or click on `Tools` and `Install Packages...`
![](./img/formationR_installTidyverse.png)
\
```R ```R
typeof(x + 0.5) install.packages("ggplot2")
``` ```
\pause ### Loading packages
```R ```{r packagesstep1, include=TRUE}
is.vector(x) sessionInfo()
``` ```
\pause \
```R ```{r packagesstep2, include=TRUE}
y <- c(a = 1, b = 2, c = 3, d = 4, e = 5) library(tidyverse)
typeof(y)
is.vector(y)
``` ```
\pause
```R ```R
x == y sessionInfo()
```
### Unloading packages
```{r packagesstep4, include=TRUE}
unloadNamespace("tidyverse")
``` ```
\pause
```R ```R
all.equal(x, y) sessionInfo()
``` ```
\
##See you to Session#2 : "Introduction to Tidyverse"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment