sampleDS {dsBase}R Documentation

random sampling and permuting of vectors, dataframes and matrices

Description

draws a pseudorandom sample from a vector, dataframe or matrix on the serverside or - as a special case - randomly permutes a vector, dataframe or matrix.

Usage

sampleDS(
  x.transmit,
  size.transmit,
  replace.transmit = NULL,
  prob.transmit = NULL
)

Arguments

x.transmit

Either a character string providing the name for the serverside vector, matrix or data.frame to be sampled or permuted, or an integer/numeric scalar (e.g. 923) indicating that one should create a new vector on the serverside that is a randomly permuted sample of the vector 1:923. x.transmit is fully specified by the [x] argument of ds.sample. For further details see help for ds.sample and native R help for sample().

size.transmit

a numeric/integer scalar indicating the size of the sample to be drawn. size.transmit is fully specified by the [size] argument of ds.sample. For further details see help for ds.sample and native R help for sample().

replace.transmit

a Boolean indicator (TRUE or FALSE) specifying whether the sample should be drawn with or without replacement. Default is FALSE so the sample is drawn without replacement. replace.transmit is fully specified by the [replace] argument of ds.sample. For further details see help for ds.sample and native R help for sample().

prob.transmit

a character string containing the name of a numeric vector of probability weights on the serverside that is associated with each of the elements of the vector to be sampled enabling the drawing of a sample with some elements given higher probability of being drawn than others. prob.transmit is fully specified by the [prob] argument of ds.sample. For further details see help for ds.sample and native R help for sample().

Details

Serverside assign function sampleDS called by clientside function ds.sample. Based on the native R function sample() but deals slightly differently with data.frames and matrices. For further details see help for ds.sample and native R help for sample().

Value

the object specified by the <newobj> argument (or default name 'newobj.sample') which is written to the serverside. For further details see help for ds.sample and native R help for sample().

Author(s)

Paul Burton, for DataSHIELD Development Team, 15/4/2020


[Package dsBase version 6.0.1 ]