Description Usage Arguments Value Examples
Subset a data frame and apply a function to that portion of it defined by a column named batch
1 | subset_apply(k, df, my_fun, seed = NULL)
|
k |
batch id to select |
df |
data frame to subset |
my_fun |
function to apply |
seed |
seed value to add to batch id, makes simulations reproducible. Default is NULL, don't set seed. |
output of function my_fun
1 2 3 4 5 6 7 8 9 | test_df <- data.frame(batch=1:10, x=rnorm(10))
test_df
test_fun <- function(df) {df$y <- df$x * rnorm(1); return(df)}
test_fun(test_df)
test_fun(test_df[1:3,])
subset_apply(1, test_df, test_fun)
subset_apply(1, test_df, test_fun)
subset_apply(1, test_df, test_fun, seed=1001)
subset_apply(1, test_df, test_fun, seed=1001)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.