forked from openpharma/visR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
213 lines (168 loc) · 6.73 KB
/
README.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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
---
output: github_document
---
<!-- README.md is generated from README.Rmd as part of the CICD process. -->
<!-- Please edit README.Rmd - but you do not need to build it! -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(visR)
#library(riskmetric)
riskmetric_score <- "visR" %>%
riskmetric::pkg_ref() %>%
dplyr::as_tibble() %>%
riskmetric::pkg_assess() %>%
riskmetric::pkg_score() %>%
dplyr::pull("pkg_score") %>%
round(2)
```
# visR <img src='man/figures/logo.png' align="right" height="131.5" />
The goal of visR is to enable fit-for-purpose, reusable clinical and medical research focused visualizations and tables with sensible defaults and based on sound [graphical principles](https://graphicsprinciples.github.io/).
[Package documentation](https://openpharma.github.io/visR/)
## Motivation
By using a common package for visualising data analysis results in the clinical development process, we want to have a **positive influence** on
* **choice of visualisation** by making it easy explore different visualisation and to use impactful visualisations fit-for-purpose
* effective visual communication by making it easy to **implement best practices**
We are not judging on what visualisation you chose for your research question, but want to facilitate and support good practice.
You can read more about the philosophy and architecture in the [repo wiki](https://github.com/openpharma/visR/wiki).
## Lifecycle and status
The package is still experimental and under active development with a current focus on developing a stable API.
<!-- badges: start -->
| Badge | Description
|----------------------|-------------------|
| [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) | Development stage |
| [![Codecov test coverage](https://codecov.io/gh/openpharma/visR/branch/develop/graph/badge.svg)](https://codecov.io/gh/openpharma/visR?branch=main) | Unit testing coverage - on `main` |
| [![R-CMD-check](https://github.com/openpharma/visR/actions/workflows/check-standard.yaml/badge.svg?branch=main)](https://github.com/openpharma/visR/actions/workflows/check-standard.yaml) | `main` branch |
| [![pkgdown](https://github.com/openpharma/visR/actions/workflows/makedocs.yml/badge.svg)](https://github.com/openpharma/visR/actions/workflows/makedocs.yml) | Documentation building to [Github pages](https://openpharma.github.io/visR/) |
| [![CRAN status](https://www.r-pkg.org/badges/version/visR)](https://CRAN.R-project.org/package=visR)| Latest CRAN release |
| <a href=https://github.com/pharmaR/riskmetric><img src=https://img.shields.io/badge/riskmetric-`r riskmetric_score`-green></img></a>| `riskmetric` score |
<!-- badges: end -->
## Installation
The easiest way to get `visR` is to install from CRAN:
``` r
install.packages("visR")
```
Install the *development* version from [GitHub](https://github.com/) with:
``` r
# defaults to develop branch
devtools::install_github("openpharma/visR")
```
Install the *latest stable* version from [GitHub](https://github.com/) with:
``` r
devtools::install_github("openpharma/visR", ref = "main")
```
## Example
This is a basic example to demonstrate how the API can be used to add layers to a visualization. In this example a time to event analysis. The example calculates stratified Kaplan-Meier by treatment and then plots. Additional functions can be used to add uncertainty intervals, censoring information and a risk table.
```{r example, warning=FALSE, message = FALSE}
library(visR)
library(ggplot2)
theme_set(theme_minimal())
adtte %>%
estimate_KM(strata = "TRTP", conf.int = 0.90) %>%
visr(legend_position = "right", x_unit = "Days") %>%
add_CI(style = "ribbon") %>%
add_CNSR(shape = 3, size = 1) %>%
add_risktable(
statlist = c("n.risk", "n.event", "n.censor"),
label = c("At risk", "Event", "Censor")
)
```
## Contribution
Please note that the `visR` project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
```{r getcontributions, echo=FALSE, warning=FALSE, message = FALSE}
library(dplyr)
library(ggplot2)
#library(GithubMetrics) #remotes::install_github("openpharma/GithubMetrics")
library(gitsum) #remotes::install_github("lorenzwalthert/gitsum")
local_repo <- parse_log_detailed()
# commits <- gh_commits_get(
# full_names = "openpharma/visR",
# days_back = 365*10,
# .token = Sys.getenv("GH_API_TOKEN_README")
# ) %>%
# mutate(date = as.Date(datetime)) %>%
# filter(!author %in% c(".gitconfig missing email","actions-user"))
#
# left_join(
# commits %>%
# group_by(author) %>%
# summarise(commits_all = n()),
# commits %>%
# filter(date > Sys.Date() - 28*6) %>%
# group_by(author) %>%
# summarise(commits_6months = n())
# ) %>%
# arrange(-commits_6months) %>%
# left_join(
# gh_user_get(unique(commits$author),
# .token = Sys.getenv("GH_API_TOKEN_README")
# ),
# by = c("author"="username")
# ) %>%
# mutate(
# blog = case_when(
# blog == "" ~ "",
# TRUE ~ as.character(paste0('<a href="', blog, '">link</a>'))
# ),
# author = case_when(
# !is.na(name) ~ paste0(name,"(",author,")"),
# TRUE ~ author
# ),
# author = paste0('<img src="', avatar, '" alt="" height="30"> ', author)
# ) %>%
# select(author,commits_all,commits_6months,company,location,blog) %>%
# knitr::kable()
```
```{r plotcontriuptake, echo=FALSE, warning=FALSE, message = FALSE}
# plot
local_repo %>%
arrange(
date
) %>%
group_by(author_email) %>%
slice(1) %>% ungroup %>%
ggplot(aes(x = date)) +
stat_bin(aes(y = cumsum(..count..)),geom = "step") +
theme_minimal() +
labs(
title = "Uptake in new contributors to visR",
subtitle = "Based email address attached to commits",
y = "Contributors",
x = "Date"
) + theme(legend.position = "none")
```
```{r plotcontributions, echo=FALSE, warning=FALSE, message = FALSE}
# plot
local_repo %>%
mutate(date = gsub("([0-9]{4}\\-[0-9]{2})\\-.*","\\1", date)) %>%
mutate(date = as.POSIXct(paste0(date, "-01 UTC"), tz = "UTC")) %>%
group_by(
Month = date,
author_name
) %>%
summarise(
Commits = n()
) %>%
ggplot() +
geom_col(
aes(x = Month, y = Commits, fill = author_name)
) +
theme_minimal() +
labs(
title = "Commit activity in openpharma/visR",
subtitle = "Colour = author (names hidden)"
) + theme(legend.position = "none")
```
## Code coverage
Last time readme built.
```{r}
covr::package_coverage(
type = "none",
code = "tools::testInstalledPackage(pkg = 'visR', types = c('tests'))",
quiet = FALSE
)
```