-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
145 lines (113 loc) · 5.19 KB
/
Copy pathREADME.Rmd
File metadata and controls
145 lines (113 loc) · 5.19 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# mantis
<!-- badges: start -->
[](https://github.com/ropensci/mantis/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/ropensci/mantis)
[](https://www.repostatus.org/#active)
[](https://github.com/ropensci/software-review/issues/710)
<!-- badges: end -->
The `mantis` package generates interactive reports that enable quick visual
review of multiple related time series stored in a data frame. This can help
with identification of temporal artefacts and unexpected trends. The choice of
visualisations include interactive plots with adjustable axes and tooltips
showing the individual dates and values, as well as static heatmap and scatter
plots for more lightweight applications. E.g.
<img src="man/figures/example_prescription_numbers_interactive.png" width="350" /><img src="man/figures/example_prescription_numbers_heatmap.png" width="350" />
The resulting html reports are self-contained and shareable without a web server.
Example reports and more detailed guidance can be found in the [package
website](https://ropensci.github.io/mantis/index.html), including how to
add [alerting
rules](https://ropensci.github.io/mantis/articles/alert-rules.html) and how to
add `mantis` visualisations to your own [bespoke
reports](https://ropensci.github.io/mantis/articles/bespoke-reports.html).
## Why should I use it?
We anticipate two main target users:
1. Researchers who analyse data from large, temporal datasets, particularly
routinely-collected data such as electronic health records. Included as part of
the initial analysis stage, it will help you to check for any temporal biases in
your datasets before embarking on your main analyses, therefore improving the
reliability of your study.
2. Managers of live data feeds that are used as a data source for downstream
analyses. Regular inspection of data that is frequently updated will help to
identify any issues early and enable a timely response to rectify issues such as
missing data. While a set of validation checks in a data pipeline could also
work in this circumstance, the benefit of this package is the ability to check
for temporal anomalies that are obvious to the human eye but that are difficult
to capture programmatically.
## Installation
```{r, eval = FALSE}
# install from CRAN
install.packages("mantis")
# or install the current development version
# either from rOpenSci
install.packages("mantis",
repos = c('https://ropensci.r-universe.dev',
'https://cloud.r-project.org'))
# or direct from source
# install stable dependencies first
install.packages(c(
"remotes",
"rmarkdown",
"knitr",
"reactable",
"dplyr",
"tidyr",
"dygraphs",
"xts",
"ggplot2",
"scales",
"purrr",
"htmltools",
"lubridate"
))
# install.packages("remotes")
remotes::install_github("ropensci/mantis", dependencies = FALSE)
```
## Usage
```{r}
library(mantis)
# this example data frame contains numbers of antibiotic prescriptions
# in long format
data("example_prescription_numbers")
head(example_prescription_numbers)
```
```{r, eval = FALSE}
# create a report in the working directory, with one tab per Location
mantis_report(
df = example_prescription_numbers,
file = "example_prescription_numbers_report.html",
inputspec = inputspec(
timepoint_col = "PrescriptionDate",
item_cols = c("Location", "Antibiotic", "Spectrum"),
value_col = "NumberOfPrescriptions",
tab_col = "Location",
timepoint_unit = "day"
)
)
```
## Relation to other packages
`mantis` is designed for use on data that is essentially a collection of time
series in a data frame, where you have already decided which values you are
interested in reviewing. If you want to check more generally for temporal
changes in record-level, non-numeric data, then check out our sister package
[`daiquiri`](https://ropensci.github.io/daiquiri/index.html).
If you are not specifically interested in temporal changes, you could try
visually inspecting your data frames with
[`visdat`](https://docs.ropensci.org/visdat/), or run validation checks on them
with [`assertr`](https://docs.ropensci.org/assertr/articles/assertr.html) or
[`pointblank`](https://rstudio.github.io/pointblank/).
## Acknowledgements
This work was supported by the National Institute for Health Research Health
Protection Research Unit (NIHR HPRU) in Healthcare Associated Infections and
Antimicrobial Resistance at the University of Oxford in partnership with the UK
Health Security Agency (UKHSA) (NIHR200915), and by the NIHR Oxford Biomedical
Research Centre.
## Contributing to this package
Please report any bugs or suggestions by opening a [github
issue](https://github.com/ropensci/mantis/issues).