Sample or subset records from a matrix or a data.frame

Sample or subset records from a matrix or a data.frame

sampleIDs(data, Nsamples)

Arguments

data

a data.frame describing patient or other subject covariate and regressor data. If nrow(data)==Nsamples, then all rows in data are returned (in their original order) in the resulting data.frame; if nrow(data)>Nsamples, sampling without replacement from the rows in data is done; if nrow(data)<Nsamples then sampling with replacement is done.

Nsamples

integer denoting the number of individuals in a population. Note: in the case of FLAG_SAMPLE=2, this value is used to specify the number of populations (see Npop). Default: if(is.IQRnlmeParamSpec(obj)) obj$Nsamples else 1L.

Value

a data.frame. If nrow(data)==Nsamples, then all rows in data are included (in their original order); if nrow(data)>Nsamples, sampling without replacement from the rows in data is done; if nrow(data)<Nsamples then sampling with replacement is done. The returned data.frame has a column ID set to the integers 1:Nsamples. If the original data object did have a column ID, this column is copied as a column ID0 in the returned data.frame.

See also

Examples

if (FALSE) { #See the examples for sampleIndParamValues: ?sampleIndParamValues }