Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

draw

Draw a single observation out of an object matching some criteria


Description

Draw is used to select a single observation out of an R object. Additional parameters allow the user to control how that observation is chosen in order to manipulate that observation later. This is a generic function with methods for a number of objects.

Usage

draw(object, type = c("random", "average"), varList = NULL, seed = NULL, ...)

## S3 method for class 'merMod'
draw(object, type = c("random", "average"), varList = NULL, seed = NULL, ...)

Arguments

object

the object to draw from

type

what kind of draw to make. Options include random or average

varList

a list specifying filters to subset the data by when making the draw

seed

numeric, optional argument to set seed for simulations, ignored if type="average"

...

additional arguments required by certain methods

Details

In cases of tie, ".", may be substituted for factors.

Value

a data.frame with a single row representing the desired observation

Examples

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
# Random case
draw(fm1, type = "random")
# Average
draw(fm1, type = "average")
# Subset
draw(fm1, type = "average", varList = list("Subject" = "308"))

merTools

Tools for Analyzing Mixed Effect Regression Models

v0.5.2
GPL (>= 2)
Authors
Jared E. Knowles [aut, cre], Carl Frederick [aut], Alex Whitworth [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.