Recently I got to know that the map function from purrr package is really powerful and tried to find out how to use it in the following case:
Using iris dataset and using purrr::map function, calculate max, mean, min for all variables Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, respectively for each Species (setosa, versicolor, virginica). Then put the results into a list having
- a character: Species name, and
- four vectors:
max,mean,minforSepal.Length,Sepal.Width,Petal.Length,Petal.Width.
Any suggestions? I was using dplyr::mutate, but the result format is not what I want.
iris %>% group_by(Species) %>% summarise(MinSL=min(Sepal.Length), MaxSL=max(Sepal.Length), MeanSL=mean(Sepal.Length), MinPL=min(Petal.Length), MaxPL=max(Petal.Length), MeanPL=mean(Petal.Length)) It will be also nice see if there is a solution using dpylr to do the task. Thank you!