https://github.com/insightsengineering/dunlin
Tools for Clinical Trial Data Wrangling
https://github.com/insightsengineering/dunlin
Last synced: about 1 year ago
JSON representation
Tools for Clinical Trial Data Wrangling
- Host: GitHub
- URL: https://github.com/insightsengineering/dunlin
- Owner: insightsengineering
- License: other
- Created: 2022-02-11T18:52:01.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-09T14:32:14.000Z (about 1 year ago)
- Last Synced: 2025-04-09T15:21:29.982Z (about 1 year ago)
- Language: R
- Homepage: https://insightsengineering.github.io/dunlin/
- Size: 14.1 MB
- Stars: 4
- Watchers: 8
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# `dunlin`: Tools for Clinical Trial Data Wrangling
[](https://insightsengineering.github.io/dunlin/main/unit-test-report/)
[](https://insightsengineering.github.io/dunlin/)
[](https://insightsengineering.github.io/dunlin/main/coverage-report/)








[](https://www.repostatus.org/#active)
[](https://github.com/insightsengineering/dunlin/tree/main)
[](https://github.com/insightsengineering/dunlin/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
`dunlin` provides a variety of data tools to reformat and manipulate a subset of the tables in a data set.
## Installation
```r
# install.packages("pak")
pak::pak("insightsengineering/dunlin@*release")
```
Alternatively, you might also use the development version.
```r
# install.packages("pak")
pak::pak("insightsengineering/dunlin")
```
## Usage
```r
library(dunlin)
df1 <- data.frame(
"id" = c("a", "b", NA, "a", "k", "x"),
"id2" = factor(c("f1", "f2", NA, NA, "f1", "f1")),
"val" = letters[1:6]
)
df2 <- data.frame(
"id" = c("a", "b", NA, "a", "k", "x"),
"id2" = factor(c("f1", "f2", NA, NA, "f1", "f1")),
"num" = 1:6
)
db <- list(df1 = df1, df2 = df2)
prop_db <- propagate(db, "df1", "val", c("id", "id2"))
```
which returns `prop_db` as
```text
$df1
id id2 val
1 a f1 a
2 b f2 b
3 c
4 a d
5 k f1 e
6 x f1 f
$df2
id id2 num val
1 a f1 1 a
2 b f2 2 b
3 3 c
4 a 4 d
5 k f1 5 e
6 x f1 6 f
```
```r
new_format <- list(
df1 = list(
id = rule("No ID available" = c("", NA, "")),
id2 = rule("" = c("", NA, ""))
)
)
res <- reformat(prop_db, new_format, .na_last = TRUE)
```
which result in `res` as
```text
$df1
id id2 val
1 a f1 a
2 b f2 b
3 No ID available c
4 a d
5 k f1 e
6 x f1 f
$df2
id id2 num val
1 a f1 1 a
2 b f2 2 b
3 3 c
4 a 4 d
5 k f1 5 e
6 x f1 6 f
```
## Stargazers and Forkers
### Stargazers over time
[](https://starchart.cc/insightsengineering/dunlin)
### Stargazers
[](https://github.com/insightsengineering/dunlin/stargazers)
[](https://github.com/insightsengineering/dunlin/network/members)