sampleCovs | R Documentation |
Repeats a data set with just one subject by sampling covariates from subjects in an existing data set. This can conveniently be used to generate new subjects with covariate resampling from an studied population.
sampleCovs(
data,
Nsubjs,
col.id = "ID",
col.id.covs = "ID",
data.covs,
covs,
seed.R,
as.fun
)
data |
A simulation data set with only one subject |
Nsubjs |
The number of subjects to be sampled. This can be greater than the number of subjects in data.covs. |
col.id |
Name of the subject ID column in 'data' (default is "ID"). |
col.id.covs |
Name of the subject ID column in 'data.covs' (default is "ID"). |
data.covs |
The data set containing the subjects to sample covariates from. |
covs |
The name of the covariates (columns) to sample from 'data.covs'. |
seed.R |
If provided, passed to 'set.seed()'. |
as.fun |
The default is to return data as a data.frame. Pass a function (say 'tibble::as_tibble') in as.fun to convert to something else. If data.tables are wanted, use as.fun="data.table". The default can be configured using NMdataConf. |
A data.frame
library(NMdata)
data.covs <- NMscanData(system.file("examples/nonmem/xgxr134.mod",package="NMsim"))
dos.1 <- NMcreateDoses(TIME=0,AMT=100)
data.sim.1 <- NMaddSamples(dos.1,TIME=c(1,4),CMT=2)
sampleCovs(data=data.sim.1,Nsubjs=3,col.id.covs="ID",data.covs=data.covs,covs=c("WEIGHTB","eff0"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.