From 9953af68dbb16a75e52fde17011f487127035009 Mon Sep 17 00:00:00 2001 From: hpolvech <helene.polveche@ens-lyon.fr> Date: Mon, 23 Mar 2020 12:03:25 +0100 Subject: [PATCH] HTML_tuto: terminated --- session_1/HTML_tuto.Rmd | 167 +++++++++++++++++++++++++--------------- 1 file changed, 106 insertions(+), 61 deletions(-) diff --git a/session_1/HTML_tuto.Rmd b/session_1/HTML_tuto.Rmd index ea4134d..2404bd0 100644 --- a/session_1/HTML_tuto.Rmd +++ b/session_1/HTML_tuto.Rmd @@ -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.).  - -### 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...` + + + + \ ```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" -- GitLab