-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
75 lines (56 loc) · 2.93 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# metatools <a href='https://github.com/pharmaverse/metatools'><img src="man/figures/metatools.png" align="right" style="height:139px;"/></a>
<!-- badges: start -->
[<img src="http://pharmaverse.org/shields/metatools.svg"/>](https://pharmaverse.org) [![R-CMD-check](https://github.com/pharmaverse/metatools/workflows/R-CMD-check/badge.svg)](https://github.com/pharmaverse/metatools/actions) [![codecov](https://codecov.io/gh/pharmaverse/metatools/branch/main/graph/badge.svg?token=55N5APFLPA)](https://app.codecov.io/gh/pharmaverse/metatools) [<img src="https://img.shields.io/badge/License-MIT-blue.svg"/>](https://github.com/pharmaverse/metatools/blob/main/LICENSE) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/pharmaverse/metatools/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pharmaverse/metatools/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of metatools is to enable the use of metacore objects. Metatools can be used to build datasets or enhance columns in existing datasets as well as checking datasets against the metadata in metacore.
## Installation
You can install the latest released version of metatools from CRAN with:
``` {r, eval = FALSE}
install.packages("metatools")
```
And the current development version from [GitHub](https://github.com/pharmaverse/metatools) with:
``` {r, eval = FALSE}
devtools::install_github("pharmaverse/metatools")
```
## Example
Here is a basic example of some functions to build datasets and create new columns.
```{r example}
library(metatools)
library(metacore)
library(haven)
library(dplyr)
load(metacore_example("pilot_ADaM.rda"))
metacore <- metacore %>%
select_dataset("ADSL")
ds_list <- list(DM = read_xpt(metatools_example("dm.xpt")))
# Pull in columns from DM to be in ADSL
adsl <- build_from_derived(metacore, ds_list, predecessor_only = FALSE)
adsl
# Now we can make some new columns and converting columns into factors
adsl %>%
select(USUBJID, AGE, ETHNIC) %>%
create_cat_var(metacore, AGE, AGEGR1, AGEGR1N) %>% #Add an AGEGR1 and AGEGR1N column
convert_var_to_fct(metacore, ETHNIC) # Change ETHNIC to as factor
```
Metatools can also be used to run checks
```{r}
data <- read_xpt(metatools_example("adsl.xpt"))
# Checks can be run on a single column
check_ct_col(data, metacore, TRT01PN) # Checks column only contains control terminology
# Or across all the columns
check_ct_data(data, metacore) %>% # Checks control terminology for all columns
check_variables(metacore) # Check all variables in the metadata are in the dataset and there aren't any extra columns
```