From c031713c07f138916c3bb4e8a0980e44332d2d16 Mon Sep 17 00:00:00 2001 From: Carine Rey <carine.rey@ens-lyon.fr> Date: Tue, 6 Sep 2022 17:24:41 +0200 Subject: [PATCH] put bioincoductor/github installing tuto in the main file (session1) --- session_1/bioconductor.Rmd | 41 ------------------------------- session_1/github.Rmd | 50 -------------------------------------- session_1/session_1.Rmd | 48 +++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 92 deletions(-) delete mode 100644 session_1/bioconductor.Rmd delete mode 100644 session_1/github.Rmd diff --git a/session_1/bioconductor.Rmd b/session_1/bioconductor.Rmd deleted file mode 100644 index a207936..0000000 --- a/session_1/bioconductor.Rmd +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: 'R.1: Installing packages from Bioconductor' -author: "Carine Rey [carine.rey@ens-lyon.fr](mailto:carine.rey@ens-lyon.fr), Laurent Modolo [laurent.modolo@ens-lyon.fr](mailto:laurent.modolo@ens-lyon.fr)" -date: "2021" -output: - rmdformats::downcute: - self_contain: true - use_bookdown: true - default_style: "dark" - lightbox: true - css: "../src/style.css" ---- - -```{r setup, include=FALSE} -rm(list=ls()) -knitr::opts_chunk$set(echo = TRUE) -knitr::opts_chunk$set(comment = NA) -``` -```{r klippy, echo=FALSE, include=TRUE} -klippy::klippy( - position = c('top', 'right'), - color = "white", - tooltip_message = 'Click to copy', - tooltip_success = 'Copied !') -``` - -To install packages from [bioconductor](http://www.bioconductor.org) you must first install a package called "BiocManager". -This package imports a function called "install" allowing you to install packages hosted in bioconductor from their name. - -To install "BiocManager" you must type: - -```R -install.packages("BiocManager") -``` - -Then to install, for example "tximport", you just have to write: - -```R -BiocManager::install("tximport") -``` - diff --git a/session_1/github.Rmd b/session_1/github.Rmd deleted file mode 100644 index 4df196a..0000000 --- a/session_1/github.Rmd +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: 'R.1: Installing packages from github' -author: "Carine Rey [carine.rey@ens-lyon.fr](mailto:carine.rey@ens-lyon.fr), Laurent Modolo [laurent.modolo@ens-lyon.fr](mailto:laurent.modolo@ens-lyon.fr)" -date: "2021" -output: - rmdformats::downcute: - self_contain: true - use_bookdown: true - default_style: "dark" - lightbox: true - css: "../src/style.css" ---- - -```{r setup, include=FALSE} -rm(list=ls()) -knitr::opts_chunk$set(echo = TRUE) -knitr::opts_chunk$set(comment = NA) -``` -```{r klippy, echo=FALSE, include=TRUE} -klippy::klippy( - position = c('top', 'right'), - color = "white", - tooltip_message = 'Click to copy', - tooltip_success = 'Copied !') -``` - -If you need to install a package that is not available on the CRAN but on a github repository, you can do it using the "remotes" package. Indeed this package imports functions that will allow you to install a package available on [github](https://github.com/) or bitbucket or gitlab directly on your computer. - -To use the "remotes" packages, you must first install it: - -```R -install.packages("remotes") -``` - -Once "remotes" is installed, you will be able to install all R package from github or from their URL. - -For example, if you want to install the last version of a "gganimate", which allow you to animate ggplot2 graphes, you can use : - -```R -remotes::install_github("thomasp85/gganimate") -``` - -By default the latest version of the package is installed, if you want a given version you can specify it : - -```R -remotes::install_github("thomasp85/gganimate@v1.0.7") -``` - -You can find more information in the documentation of remotes : [https://remotes.r-lib.org](https://remotes.r-lib.org) - diff --git a/session_1/session_1.Rmd b/session_1/session_1.Rmd index 662dd28..0ca151f 100644 --- a/session_1/session_1.Rmd +++ b/session_1/session_1.Rmd @@ -84,7 +84,7 @@ Reasons to use it: - It has a large (and growing) user base among scientists - It has a large library of external packages available for performing diverse tasks. -```{r echo=F} +```{r echo=F, message=F} cran_packages <- nrow(available.packages(repos = "http://cran.us.r-project.org")) if (! require("rvest")) { @@ -491,6 +491,7 @@ Instead we are going to use the Rstudio code editor panel, to write our code. You can go to **File > New File > R script** to open your editor panel.  + ## Writing function We can define our own function with : @@ -719,6 +720,8 @@ To install packages from [Bioconducor](http://www.bioconductor.org) and [github] ## Installing packages +### From CRAN + To install packages, you can use the `install.packages` function (don't forget to use tabulation for long variable names). ```R @@ -740,6 +743,49 @@ install.packages("ggplot2") </p> </details> +### From Bioconducor + +To install packages from [bioconductor](http://www.bioconductor.org) you must first install a package called "BiocManager". +This package imports a function called "install" allowing you to install packages hosted in bioconductor from their name. + +To install "BiocManager" you must type: + +```R +install.packages("BiocManager") +``` + +Then to install, for example "tximport", you just have to write: + +```R +BiocManager::install("tximport") +``` + +### From github + +If you need to install a package that is not available on the CRAN but on a github repository, you can do it using the "remotes" package. Indeed this package imports functions that will allow you to install a package available on [github](https://github.com/) or bitbucket or gitlab directly on your computer. + +To use the "remotes" packages, you must first install it: + +```R +install.packages("remotes") +``` + +Once "remotes" is installed, you will be able to install all R package from github or from their URL. + +For example, if you want to install the last version of a "gganimate", which allow you to animate ggplot2 graphes, you can use : + +```R +remotes::install_github("thomasp85/gganimate") +``` + +By default the latest version of the package is installed, if you want a given version you can specify it : + +```R +remotes::install_github("thomasp85/gganimate@v1.0.7") +``` + +You can find more information in the documentation of remotes : [https://remotes.r-lib.org](https://remotes.r-lib.org) + ## Loading packages Once a package is installed, you need to load it in your R session to be able to use it. -- GitLab