Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional text to vignette 1 #20

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Imports:
Depends:
R (>= 2.10)
Suggests:
ggplot2,
knitr,
rmarkdown,
testthat (>= 3.0.0)
Expand Down
7 changes: 7 additions & 0 deletions man/omock-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 37 additions & 3 deletions vignettes/a01_Creating_synthetic_clinical_tables.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "a01_Creating_synthetic_clinical_tables"
title: "Creating synthetic clinical tables"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{a01_Creating_synthetic_clinical_tables}
Expand All @@ -14,8 +14,42 @@ knitr::opts_chunk$set(
)
```

```{r setup}
The omock package provides functionality to quickly create a cdm reference containing synthetic data based on population settings specified by the user.

First, let's load packages required for this vignette.
```{r, message=FALSE, warning=FALSE}
library(omock)
library(dplyr)
library(ggplot2)
```

Here we explain making a mock cdm table using mockPerson, mockObservationPeriod, etc
Now, in three lines of code, we can create a cdm reference with a person and observation period table for 1000 people.
```{r}
cdm <- emptyCdmReference(cdmName = "synthetic cdm") %>%
mockPerson(nPerson = 1000) %>%
mockObservationPeriod()

cdm

cdm$person %>% glimpse()

cdm$observation_period %>% glimpse()
```

We can add further requirements around the population we create. For example we can require that they were born between 1960 and 1980 like so.
```{r}
cdm <- emptyCdmReference(cdmName = "synthetic cdm") %>%
mockPerson(nPerson = 1000,
birthRange = c("1960-01-01", "1980-12-31")) %>%
mockObservationPeriod()
```

```{r}
cdm$person %>%
collect() %>%
ggplot() +
geom_histogram(aes(as.integer(year_of_birth)),
binwidth = 1, colour = "grey") +
theme_minimal() +
xlab("Year of birth")
```
2 changes: 1 addition & 1 deletion vignettes/a02_Creating_synthetic_cohorts.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "a02_Creating_synthetic_cohorts"
title: "Creating synthetic cohorts"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{a02_Creating_synthetic_cohorts}
Expand Down