diff --git a/R/vpcstats.R b/R/vpcstats.R index 708d789..73fd805 100644 --- a/R/vpcstats.R +++ b/R/vpcstats.R @@ -129,6 +129,7 @@ simulated.tidyvpcobj <- function(o, data, ysim, ..., xsim) { #' values for lower/upper limit of quantification. Logicals for \code{blq} and \code{alq} are returned that indicate whether the DV value lies below/above limit #' of quantification. #' @examples +#' \donttest{ #' require(magrittr) #' #' vpc <- observed(obs_data, x=TIME, y=DV) %>% @@ -147,7 +148,7 @@ simulated.tidyvpcobj <- function(o, data, ysim, ..., xsim) { #' stratify(~ STUDY) %>% #' binning(bin = "kmeans", nbins = 4) %>% #' vpcstats() -#' +#' } #' #' @seealso \code{\link{observed}} \code{\link{simulated}} \code{\link{stratify}} \code{\link{predcorrect}} \code{\link{binning}} \code{\link{binless}} \code{\link{vpcstats}} @@ -245,6 +246,7 @@ censoring.tidyvpcobj <- function(o, blq, lloq, alq, uloq, data=o$data, ...) { #' is \code{obs} split by unique levels of stratification variable(s). Resulting datasets are of class object \code{data.frame} #' and \code{data.table}. #' @examples +#' \donttest{ #' require(magrittr) #' #' vpc <- observed(obs_data, x=TIME, y=DV) %>% @@ -259,6 +261,7 @@ censoring.tidyvpcobj <- function(o, blq, lloq, alq, uloq, data=o$data, ...) { #' stratify(~ GENDER + STUDY) %>% #' binning(bin = "centers", centers = c(1,3,5,7,10)) %>% #' vpcstats() +#' } #' #' @seealso \code{\link{observed}} \code{\link{simulated}} \code{\link{censoring}} \code{\link{predcorrect}} \code{\link{binning}} \code{\link{binless}} \code{\link{vpcstats}} @@ -557,6 +560,7 @@ binning.tidyvpcobj <- function(o, bin, data=o$data, xbin="xmedian", centers, bre #' prediction corrected VPC is to be performed, the \code{predcor.log} logical indicating whether the DV is on a log-scale, and the \code{pred} prediction #' column from the original data. #' @examples +#' \donttest{ #' require(magrittr) #' #' obs_data <- obs_data[MDV == 0] @@ -573,7 +577,6 @@ binning.tidyvpcobj <- function(o, bin, data=o$data, xbin="xmedian", centers, bre #' predcorrect(pred=PRED) %>% #' vpcstats() #' -#' \donttest{ #' # For binless loess prediction corrected, use predcorrect() before #' # binless() and set loess.ypc = TRUE #' diff --git a/man/censoring.Rd b/man/censoring.Rd index 3d246de..6042efe 100644 --- a/man/censoring.Rd +++ b/man/censoring.Rd @@ -33,6 +33,7 @@ Updates \code{obs} \code{data.frame} in \code{tidypcobj} with censored values fo Specify censoring variable or censoring value for VPC. } \examples{ +\donttest{ require(magrittr) vpc <- observed(obs_data, x=TIME, y=DV) \%>\% @@ -51,7 +52,7 @@ vpc <- observed(obs_data, x=TIME, y=DV) \%>\% stratify(~ STUDY) \%>\% binning(bin = "kmeans", nbins = 4) \%>\% vpcstats() - +} } \seealso{ diff --git a/man/predcorrect.Rd b/man/predcorrect.Rd index f20d162..b3470a8 100644 --- a/man/predcorrect.Rd +++ b/man/predcorrect.Rd @@ -29,6 +29,7 @@ Updates \code{tidyvpcobj} with required information to performing prediction cor Specify prediction variable for pcVPC. } \examples{ +\donttest{ require(magrittr) obs_data <- obs_data[MDV == 0] @@ -45,7 +46,6 @@ obs_data$PRED <- sim_data[REP == 1, PRED] predcorrect(pred=PRED) \%>\% vpcstats() - \donttest{ # For binless loess prediction corrected, use predcorrect() before # binless() and set loess.ypc = TRUE diff --git a/man/stratify.Rd b/man/stratify.Rd index 254e4c6..268a255 100644 --- a/man/stratify.Rd +++ b/man/stratify.Rd @@ -27,6 +27,7 @@ Returns updated \code{tidyvpcobj} with stratification formula, stratification co Use to specify stratification variables for VPC. } \examples{ +\donttest{ require(magrittr) vpc <- observed(obs_data, x=TIME, y=DV) \%>\% @@ -41,6 +42,7 @@ vpc <- vpc \%>\% stratify(~ GENDER + STUDY) \%>\% binning(bin = "centers", centers = c(1,3,5,7,10)) \%>\% vpcstats() +} } \seealso{ diff --git a/tests/testthat.R b/tests/testthat.R index 190005c..330e711 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,4 +1,6 @@ library(testthat) library(tidyvpc) - +registered_threads <- data.table::getDTthreads() +data.table::setDTthreads(2) +on.exit(data.table::setDTthreads(registered_threads)) test_check("tidyvpc") diff --git a/tests/testthat/test-binless.R b/tests/testthat/test-binless.R index 676c07b..dbf43ab 100644 --- a/tests/testthat/test-binless.R +++ b/tests/testthat/test-binless.R @@ -114,6 +114,7 @@ test_that("cont vpc predcorrect binless vpcstats are correct", { }) test_that("cont vpc binless censoring vpcstats are correct", { + skip_on_cran() obs_data <- obs_data[MDV == 0] sim_data <- sim_data[MDV == 0] @@ -200,6 +201,7 @@ test_that("binless.tidyvpcobj returns correct errors and warnings", { test_that("binless.tidyvpcobj uses supplied lambda and span if optimize = FALSE", { # continuous VPC + skip_on_cran() obs_data <- obs_data[MDV == 0] sim_data <- sim_data[MDV == 0] obs_data$PRED <- sim_data[REP == 1, PRED] diff --git a/vignettes/tidyvpc_cat.Rmd b/vignettes/tidyvpc_cat.Rmd index 1bfe7f2..86ee0b4 100644 --- a/vignettes/tidyvpc_cat.Rmd +++ b/vignettes/tidyvpc_cat.Rmd @@ -18,6 +18,10 @@ library(data.table) set.seed(1014) ``` +```{r, echo=FALSE} +data.table::setDTthreads(2) +``` + ## Introduction diff --git a/vignettes/tidyvpc_cont.Rmd b/vignettes/tidyvpc_cont.Rmd index 39cf8f7..436d007 100644 --- a/vignettes/tidyvpc_cont.Rmd +++ b/vignettes/tidyvpc_cont.Rmd @@ -16,6 +16,11 @@ library(magrittr) set.seed(1014) ``` +```{r, echo=FALSE} +data.table::setDTthreads(2) +``` + + ## Introduction **When deriving a Visual Predictive Check (VPC) you must:** @@ -232,27 +237,7 @@ vpc <- observed(obs_data, x=TIME, y=DV) %>% plot(vpc, censoring.type = "blq") ``` -Censoring using `LLOQ` variable in the data. - -First, let's add an LLOQ variable to the observed data. -```{r} -obs_data$LLOQ <- 50 -``` - -Then, we'll specify lower limit of quantification as the unquoted variable name `LLOQ` in our data. Let's also provide our own lambda values. - -```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE} -vpc <- observed(obs_data, x=TIME, y=DV) %>% - simulated(sim_data, y=DV) %>% - censoring(blq=(DV < LLOQ), lloq=LLOQ) %>% - binless(optimize = FALSE, lambda = c(1.5, 2.5, 1.7)) %>% - vpcstats() - -plot(vpc, censoring.type = "blq") -``` - - -The `tidyvpc` package also allows you to use different LLOQ for each level of stratification variable. We'll set an `LLOQ` value of `50` for `Study A` and `25` for `Study B` and calculate statistics at 10%, 50%, 90% quantiles. +The `tidyvpc` package also allows you to use LLOQ values within your data and different LLOQ for each level of stratification variable. We'll set an `LLOQ` value of `50` for `Study A` and `25` for `Study B` and calculate statistics at 10%, 50%, 90% quantiles. ```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE} obs_data$LLOQ <- obs_data[, ifelse(STUDY == "Study A", 50, 25)] @@ -269,7 +254,7 @@ plot(vpc, censoring.type = "blq", facet.scales = "fixed") The `tidyvpc` package also supports usage of `censoring()` with ALQ data, similar to above usage with BLQ data. -```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE} +```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE, eval = FALSE} obs_data$ULOQ <- obs_data[, ifelse(STUDY == "Study A", 125, 100)] vpc <- observed(obs_data, x = TIME, y = DV) |> @@ -278,11 +263,10 @@ vpc <- observed(obs_data, x = TIME, y = DV) |> stratify(~ STUDY) |> binning(bin = NTIME) |> vpcstats(qpred = c(0.1, 0.5, 0.9)) - -plot(vpc, censoring.type = "alq") - ``` +To plot the above `vpc` and include the percentage of ALQ plot, you'd run `plot(vpc, censoring.type = "alq")`. + If using `censoring()` with both ALQ and BLQ data, set `censoring.type = "both"` in the `plot()` function to display both percentage of BLQ and ALQ plots as a grid in the resulting VPC plot. ```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE} diff --git a/vignettes/tidyvpc_nlmixr2.Rmd b/vignettes/tidyvpc_nlmixr2.Rmd index 3511cff..404ac55 100644 --- a/vignettes/tidyvpc_nlmixr2.Rmd +++ b/vignettes/tidyvpc_nlmixr2.Rmd @@ -14,6 +14,10 @@ knitr::opts_chunk$set( ) ``` +```{r, echo=FALSE} +data.table::setDTthreads(2) +``` + # Introduction `tidyvpc` and `nlmixr2` can work together seamlessly. The information below