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

HTML_tuto: terminated

parent 656d8814
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,10 @@ h3 { /* Header 3 */
color: #729FCF ;
left: 5%;
}
h2 { /* Header 2 */
color: darkblue ;
left: 10%;
}
h1 { /* Header 1 */
color: #034b6f ;
}
......@@ -207,7 +211,7 @@ Compute the factorial of 9 (`9!`)
```
\
**or**
or
```{r calculatorstep12, include=TRUE}
factorial(9)
```
......@@ -390,9 +394,8 @@ This block allows you to view the different outputs (?help, graphs, etc.).
![](./img/formationR_VandAstep8_encadre.png)
### Functions are also variables
\
Test that your `logarithm` function can work in base 10
......@@ -518,116 +521,158 @@ ls()
\
# Packages
## Installing packages
<fieldset id='pencadre' style='text-align: left'>
<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
install.packages("tidyverse")
```
</fieldset>
```R
install.packages("ggplot2")
\
\
# Complex variable type
### Vector (aka list)
```{r Vecstep1, include=TRUE}
c(1, 2, 3, 4, 5)
```
## Loading packages
or
```{r packagesstep1, include=TRUE}
sessionInfo()
```{r Vecstep2, include=TRUE}
c(1:5)
```
\
\
A mathematical calculation can be performed on the elements of the vector:
```{r packagesstep2, include=TRUE}
library(tidyverse)
```{r Vecstep3, include=TRUE}
2^(1:5)
```
```R
sessionInfo()
```{r Vecstep4, include=TRUE}
x <- 1:5
2^x
```
\
\
To determine the type of the elements of a vector:
```{r packagesstep4, include=TRUE}
unloadNamespace("tidyverse")
```{r Vecstep5, include=TRUE}
typeof(x)
```
```R
sessionInfo()
```{r Vecstep6, include=TRUE}
typeof(x + 0.5)
x + 0.5
```
\
# Complex variable type
## Vector (aka list)
```R
c(1, 2, 3, 4, 5)
```{r Vecstep7, include=TRUE}
is.vector(x)
```
\pause
\
\
```R
1:5
```{r Vecstep8, include=TRUE}
y <- c(a = 1, b = 2, c = 3, d = 4, e = 5)
typeof(y)
is.vector(y)
```
\pause
\
\
We can compare the elements of two vectors:
```R
2^(1:5)
```{r Vecstep9, include=TRUE}
x
y
x == y
```
\pause
\
\
If you use `all.equal` :
```R
x <- 1:5
2^x
```{r Vecstep10, include=TRUE}
all.equal(x, y)
isTRUE(all.equal(x, y))
isTRUE(all.equal(x, y, check.attributes = FALSE))
```
\
\pause
<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>
```R
log(x)
logarithm(x)
base_test(x, base = 10)
```
\
\
## Vector (aka list)
# Packages
### Installing packages
```R
typeof(x)
install.packages("tidyverse")
```
\pause
or click on `Tools` and `Install Packages...`
![](./img/formationR_installTidyverse.png)
\
```R
typeof(x + 0.5)
install.packages("ggplot2")
```
\pause
### Loading packages
```R
is.vector(x)
```{r packagesstep1, include=TRUE}
sessionInfo()
```
\pause
\
```R
y <- c(a = 1, b = 2, c = 3, d = 4, e = 5)
typeof(y)
is.vector(y)
```{r packagesstep2, include=TRUE}
library(tidyverse)
```
\pause
```R
x == y
sessionInfo()
```
### Unloading packages
```{r packagesstep4, include=TRUE}
unloadNamespace("tidyverse")
```
\pause
```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.
Finish editing this message first!
Please register or to comment