The default of "jenks" binning fails when there is a single value for a group. My first thought is that if there is a single x-value for a group then perhaps a narrow range around the x-range and do the VPC calculations just on that value with the binning as that value by itself, but there definitely could be other ideas.
The underlying error below comes from the classInt
package, but I think that makes sense for classInt
to give an error and we should probably detect single-value groups before sending it for interval selection.
library(tidyverse) #> Warning: package 'ggplot2' was built under R version 4.3.1 #> Warning: package 'purrr' was built under R version 4.3.1 library(tidyvpc) #> tidyvpc is part of Certara.R! #> Follow the link below to learn more about PMx R package development at Certara. #> https://certara.github.io/R-Certara/ d_obs <- data.frame( group = rep(c("Patient", "Healthy"), each = 5), conc = c(rep(0, 5), 1:5), value = 1:10 ) d_sim <- d_obs[rep(1:nrow(d_obs), 5), ] observed(d_obs, x = conc, yobs = value) %>% simulated(d_sim, xsim = conc, ysim = value) %>% stratify(~group) %>% binning(bin = "jenks") %>% vpcstats(qpred = c(0.1, 0.5, 0.9)) #> Error in (function (var, n, style = "quantile", rtimes = 3, ..., intervalClosure = c("left", : single unique value
Created on 2023-09-12 with reprex v2.0.2
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4