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

wiggle

Assign an observation to different values


Description

Creates a new data.frame with copies of the original observation, each assigned to a different user-specified value of a variable. Allows the user to look at the effect on predicted values of changing either a single variable or multiple variables.

Usage

wiggle(data, varlist, valueslist)

Arguments

data

a data frame with one or more observations to be reassigned

varlist

a character vector specifying the name(s) of the variable to adjust

valueslist

a list of vectors with the values to assign to var

Details

If the variable specified is a factor, then wiggle will return it as a character.

Value

a data.frame with each row assigned to the one of the new variable combinations. All variable combinations are returned, eg wiggling two variables with 3 and 4 variables respectively will return a new dataset with 3 * 4 = 12 observations.

Examples

data(iris)
wiggle(iris[3,], varlist = "Sepal.Width", valueslist = list(c(1, 2, 3, 5)))
wiggle(iris[3:5,], "Sepal.Width", valueslist = list(c(1, 2, 3, 5)))
wiggle(iris[3,], c("Sepal.Width", "Petal.Length"), list(c(1,2,3,5), c(3,5,6)))
wiggle(iris[3:5,], c("Sepal.Width", "Petal.Length"), list(c(1,2,3,5), c(3,5,6)))

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.