I am trying to create a new nested column using the data from the min and max values of another nested column.
If I nest the IRIS data by Species and want to create a new nested data frame by the min and max of the Petal.Length for each Species how would I do it?
My code so far, create a function to create a new data.frame or expand.grid, then apply it using mutate(...map(...
Code/Data:
func = function(input){
data.frame(
min_to_max = seq(
from = min(.x$Petal.Length),
to = max(.x$Petal.Length),
by = 1
)
)
}
iris %>%
group_by(Species) %>%
nest() %>%
mutate(
expandDF = map(data, ~ func(.x))
)