SwanseaUniversityMedical / concept-library

Concept Library
https://conceptlibrary.saildatabank.com
GNU General Public License v3.0
8 stars 2 forks source link

Update GitHub instructions for inside gateway #1668

Open Hannah-Davies opened 4 months ago

Hannah-Davies commented 4 months ago

Update GitHub instructions so it covers installation of packages in gateway.

See response to Help desk ticket: https://jira.hiru.swan.ac.uk/browse/HD-47452

roshantoby commented 3 months ago

= Installing Packages from GitLab in R =

== Introduction == In R, you can install packages not only from CRAN but also directly from Git repositories, including GitLab. This guide will walk you through the process of installing R packages from GitLab using different methods.

== Prerequisites ==

  1. R: Ensure you have R installed on your system. You can download it from [[http://cran.r-project.org/>>https://cran.r-project.org/]].
  2. devtools package: The devtools package is required for installing packages from Git repositories. Install it if you haven't already: {{code language="r"}} install.packages("devtools") {{/code}}
  3. git: Git should be installed on your system to clone repositories from GitLab. Download and install it from [[https://git-scm.com/>>https://git-scm.com/]].

== Installing Packages from GitLab == There are different methods to install packages from GitLab:

=== Using devtools::install_gitlab === The devtools package provides a convenient function install_gitlab for installing packages directly from a GitLab repository.

==== Basic Installation ==== To install a package from a public GitLab repository, use the following command: {{code language="r"}} devtools::install_gitlab("username/repository") {{/code}} Replace username with the GitLab username and repository with the repository name.

==== Example ==== If you want to install a package named mypackage from a user named johndoe, you would run: {{code language="r"}} devtools::install_gitlab("johndoe/mypackage") {{/code}}

=== Using Authentication for Private Repositories === For private repositories, you need to provide authentication details. You can use a personal access token for this purpose.

==== Generate a Personal Access Token ====

  1. Log in to your GitLab account.
  2. Go to Settings > Access Tokens.
  3. Create a new access token with the necessary permissions (read_repository).
  4. Copy the token for later use.

==== Installation with Access Token ==== You can pass the access token as part of the URL. Use the following format: {{code language="r"}} devtools::install_gitlab("username/repository", auth_token = "your_access_token") {{/code}} Replace your_access_token with the token you generated.

=== Using remotes::install_gitlab === The remotes package provides a similar function install_gitlab, which can also be used to install packages from GitLab.

==== Basic Installation ==== First, install the remotes package if you haven't already: {{code language="r"}} install.packages("remotes") {{/code}}

Then, use the following command to install the package: {{code language="r"}} remotes::install_gitlab("username/repository") {{/code}}

==== Installation with Access Token ==== For private repositories, you can use the access token similarly: {{code language="r"}} remotes::install_gitlab("username/repository", auth_token = "your_access_token") {{/code}}

== Conclusion == Installing packages from GitLab in R is straightforward using the devtools or remotes packages. By following the steps outlined in this guide, you can easily install both public and private packages from GitLab repositories. Make sure to handle authentication securely, especially when dealing with private repositories.