Description Usage Arguments Details Value Examples
'build_regression_data' construct a dataframe 'dat' from 'Y' and 'X' for use in a regression such as 'lm(form, data=dat)'.
1 | build_regression_data(form, Y, X)
|
form |
A formula. |
Y |
A vector. |
X |
A vector or a dataframe. |
The names of the columns of the dataframe constructed must correspond to the variables named in 'form', except in the case where the formula 'form' has a dot on the right-hand-side (e.g. Y1 ~ .). If 'X' is already a dataframe, not check is done. If it is a vector, then it is converted into a dataframe.
A dataframe.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Not run:
A <- c(1, 2)
B <- c(3, 4)
C <- c(5, 6)
X <- data.frame(X1 = B, X2 = C)
build_regression_data(Y ~ X1, A, B)
# returns:
# Y X1
# 1 3
# 2 4
build_regression_data(Y ~ ., A, B)
# returns:
# Y X
# 1 3
# 2 4
build_regression_data(Y ~ X1 + X2, A, X)
# returns:
# Y X1 X2
# 1 3 5
# 2 4 6
build_regression_data(Y ~ X1, A, X)
# returns:
# Y X1 X2
# 1 3 5
# 2 4 6
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.