-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.Rmd
107 lines (81 loc) · 2.29 KB
/
demo.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
title: "mauricer demo"
author: "Richèl J.C. Bilderbeek"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{mauricer demo}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
## Introduction
`mauricer` is an R package to handle BEAST2 package management from R,
similar to the BEAST2 package manager.
![The BEAST2 package manager](beast2_pkg_manager.png)
In this vignette, we will:
* List all BEAST2 packages
* Install the first non-installed BEAST2 package
* Verify the BEAST2 package is indeed installed
* Uninstall the BEAST2 package
To do so, we'll need to load `mauricer`. We'll also load `testthat` for testing:
```{r}
library(mauricer)
library(testthat)
```
To install BEAST2 packages, one needs
* an internet connection
* BEAST2 must be installed
If there is no internet connection, or if BEAST2 is not installed,
this vignette will be close to empty.
```{r}
if (!curl::has_internet()) {
print("No internet connection")
}
if (!beastier::is_beast2_installed()) {
print("No BEAST2 installed")
}
```
## List all BEAST2 packages
Use `get_beast2_pkg_names` to get a data frame with the name,
version and install status of all BEAST2 packages:
```{r}
if (curl::has_internet() && beastier::is_beast2_installed()) {
beast2_packages <- get_beast2_pkg_names()
knitr::kable(head(beast2_packages))
}
```
## Install the first non-installed BEAST2 package
Find a package that is not installed:
```{r}
if (curl::has_internet() && beastier::is_beast2_installed()) {
package_name <- beast2_packages[
beast2_packages$installed_version == "NA",
]$name[1]
print(package_name)
}
```
Install that package:
```
if (curl::has_internet() && beastier::is_beast2_installed()) {
mauricerinstall::install_beast2_pkg(package_name)
}
```
Note that this installation uses a non-CRAN package,
called `mauricerinstall`, as installing software
is against CRAN policy.
## Uninstall the BEAST2 package
Use `uninstall_beast2_pkg`:
```
if (curl::has_internet() && beastier::is_beast2_installed()) {
mauricerinstall::uninstall_beast2_pkg(package_name)
}
```
Also this code uses a non-CRAN package,
called `mauricerinstall`, as installing software
is against CRAN policy.