From f01ceedd60d7001b3d67add6a342f466cb57a361 Mon Sep 17 00:00:00 2001 From: edward-burn <9583964+edward-burn@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:09:06 +0000 Subject: [PATCH 1/2] additional text to vignette 1 --- ...a01_Creating_synthetic_clinical_tables.Rmd | 40 +++++++++++++++++-- vignettes/a02_Creating_synthetic_cohorts.Rmd | 2 +- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/vignettes/a01_Creating_synthetic_clinical_tables.Rmd b/vignettes/a01_Creating_synthetic_clinical_tables.Rmd index a385e0b..e641ce8 100644 --- a/vignettes/a01_Creating_synthetic_clinical_tables.Rmd +++ b/vignettes/a01_Creating_synthetic_clinical_tables.Rmd @@ -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} @@ -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") +``` diff --git a/vignettes/a02_Creating_synthetic_cohorts.Rmd b/vignettes/a02_Creating_synthetic_cohorts.Rmd index f347c4a..8d8674f 100644 --- a/vignettes/a02_Creating_synthetic_cohorts.Rmd +++ b/vignettes/a02_Creating_synthetic_cohorts.Rmd @@ -1,5 +1,5 @@ --- -title: "a02_Creating_synthetic_cohorts" +title: "Creating synthetic cohorts" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{a02_Creating_synthetic_cohorts} From 1beca05c38c7bc3981d0ba358e7321fcf1dca2c9 Mon Sep 17 00:00:00 2001 From: edward-burn <9583964+edward-burn@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:15:31 +0000 Subject: [PATCH 2/2] add ggplot to suggests --- DESCRIPTION | 1 + man/omock-package.Rd | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index fa7e6c4..62ab26a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,6 +21,7 @@ Imports: Depends: R (>= 2.10) Suggests: + ggplot2, knitr, rmarkdown, testthat (>= 3.0.0) diff --git a/man/omock-package.Rd b/man/omock-package.Rd index e009dfe..b9751e3 100644 --- a/man/omock-package.Rd +++ b/man/omock-package.Rd @@ -7,5 +7,12 @@ \title{omock: What the Package Does (Title Case)} \description{ It creates a mock omop cdm object. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://oxford-pharmacoepi.github.io/omock/} +} + } \keyword{internal}