Description Details References Examples
A set of R functions for calling the PopGen web service and for extracting data from the response.
Pay a visit to PopGen and review the inputs form before using this package for programmatic access.
Refer to the service's inputs schema for concise coverage of the input requirements.
McNally K., Cotton R., Hogg A., Loizou G. (2014). PopGen: a virtual human population generator. Toxicology 315 70-85. 10.1016/j.tox.2013.07.009 [Cross ref]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # this example samples data from all four datasets
datasets <- c("P3M", "ICRP", "HSE", "NDNS")
n_datasets <- length(datasets)
data <- lapply(1:n_datasets, function(i) {
dataset <- datasets[i]
parameters <- list(
Dataset = dataset,
PopGenUserName = "kevin.soandso@some.sci.org",
PopulationSize = 100
)
if (dataset == "NDNS") {
# See https://discover.ukdataservice.ac.uk/series/?sn=2000033#abstract
parameters$AgeLower <- 2
parameters$AgeUpper <- 4
parameters$BodyMassIndexLower <- 10
parameters$HeightLower <- 80
parameters$HeightUpper <- 120
}
parameters <- apply_defaults(parameters)
cat(paste("Sampling ", dataset, "\n", sep = ""))
# call service with no activity feedback
pop_gen_out <- generate_population(parameters, silent = T)
if (generate_failed(pop_gen_out)) {
# show error messages now
print(summary(pop_gen_out))
stop()
}
if (i < n_datasets) {
# service is throttled - must pause here
cat("Waiting for service to resume...\n")
Sys.sleep(pop_gen_out$wait_for)
}
individuals <- extract_individuals(pop_gen_out)
return(individuals)
})
names(data) <- datasets
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.