You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(dplyr)
quantile_df<-function(x, probs= c(0.25, 0.5, 0.75)) {
tibble(
val= quantile(x, probs, na.rm=TRUE),
quant=probs
)
}
# Actual Behavioiur: Removes the grouping columns and just returns cols from rowwisestarwars %>%
rowwise() %>%
reframe(quantile_df(height)) %>%
ungroup()
# 261 rows, 2 cols from quantile_df# Expected Beavhiour: Preserve them like in this codestarwars %>%
rowwise() %>%
mutate(quantiles=list(quantile_df(height))) %>%
unnest(quantiles) %>%
ungroup()
# 261 rows, all columns preserved
I want to be able to go from 1 row to multiple rows while keeping the previous information.
The use case is described below.
Use case
I was doing a simulation of the German Tank problem following a very functional/list-column heavy workflow. I have a dataframe called sensitivities which has columns that I need to generate and describe my samples. It looks like this:
I have a function called simulate_samples. Each row of the above df defines one sensitivity. Given one sensitivity, simulate_sample generates a dataframe of 100 samples with a sample_id<int> and a list column for sample<list[int]>. One row to many. So I used reframe and got the behaviour like in the minimal reprex.
The text was updated successfully, but these errors were encountered:
That's perfect. I also read the docs and I see that the simulation case is mentioned.
Thanks so much this is very useful. Look forward to see what you guys do with by-row operations in future as they are very useful for simulations and nesting calculations without loops.
Minimal reprex
I want to be able to go from 1 row to multiple rows while keeping the previous information.
The use case is described below.
Use case
sensitivities
which has columns that I need to generate and describe my samples. It looks like this:I have a function called
simulate_samples
. Each row of the above df defines one sensitivity. Given one sensitivity,simulate_sample
generates a dataframe of 100 samples with asample_id<int>
and a list column forsample<list[int]>
. One row to many. So I usedreframe
and got the behaviour like in the minimal reprex.The text was updated successfully, but these errors were encountered: