Description Usage Arguments Value Examples
dapply
splits the data df
into the subsets defined by f
,
and applies function FUN
to each of the subset.
All the results are row-binded and returned as data.frame
object.
1 |
df |
( |
f |
( |
FUN |
( |
... |
parameters passed to |
The data.frame
object with results from FUN
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | df <- data.frame(
dose = c(0.1, 6, 6, 5, 0.1, 5, 6, 6),
cohort = c("B", "B", "B", "A", "A", "A", "B", "B")
)
dapply(
df,
f = ~cohort,
FUN = function(coh) {
data.frame(my_cohort = coh$cohort[1], my_max = max(coh$dose))
}
)
dapply(
df,
f = ~cohort,
FUN = function(coh) {
coh$dose <- sort(coh$dose, decreasing = TRUE)
coh
}
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.