crossv_block | R Documentation |
This function prepares the data for block cross-validation by dividing the dataset based on the provided block variable. It creates subsets of training and testing data for each block without performing any analysis or fitting models.
crossv_block(data, y, block_var, id = ".id")
data |
A data frame containing the training data. |
y |
A response vector. |
block_var |
An integer vector defining the cross-validation blocks. |
id |
A character string specifying the identifier for the output data frame. |
A tibble containing the training and testing data, response vectors, and block IDs for each fold.
X <- data.frame(x1 = rnorm(100), x2 = rnorm(100))
y <- rep(letters[1:4], 25)
block_var <- rep(1:4, each = 25)
cv <- crossv_block(X, y, block_var)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.