Description Usage Arguments Details Value Author(s) See Also Examples
Create a response from a data set and an equation
1 | createResponseVariable(data, equation, preTest = TRUE, subsetSize = 5)
|
data |
(Required) The dataset to use, must be a |
equation |
(Required) R function that must have a |
preTest |
(Optional) Logical Flag. TRUE to try and build the response first with a
subset of the data. The subset size is given by the minimum between the number of rows in the
data and the |
subsetSize |
(Optional) Size of the subset if the |
Using the preTest
will make the function fail early if the code is wrong.
This is typically useful during the first steps of try and error. When the
user is confident that the equation
is correct, the preTest
can be set
to FALSE
.
A numeric vector corresponding to the response variable.
Mike K Smith mstoolkit@googlemail.com
addResidualError
adds a residual error to a response.
The function createResponse
is the high level function in the
response component and acts as a wrapper for createResponseVariable
and
addResidualError
.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # define a data set
myData <- data.frame( X = c(1,2,1), Y = c(1,1,1), Z = c(1,1,1) )
# function version
out1 <- createResponseVariable(data = myData, equation = function(data){
with( data, X + Y + Z)
})
# same using the character version
out2 <- createResponseVariable(data = myData, equation = "X+Y+Z")
stopifnot( identical(out1,out2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.