Learn R Programming

metan (version 1.7.0)

doo: Alternative to dplyr::do for doing anything

Description

Provides an alternative to the dplyr:do() using nest(), mutate() and map() to apply a function to a grouped data frame.

Usage

doo(.data, .fun, ...)

Arguments

.data

a (grouped) data frame

.fun

A function, formula, or atomic vector.

...

Additional arguments passed on to .fun

Value

a data frame

Details

If the applied function returns a data frame, then the output will be automatically unnested. Otherwise, the output includes the grouping variables and a column named "data" , which is a "list-columns" containing the results for group combinations.

Examples

Run this code
# NOT RUN {
library(metan)
# Head the first two lines of each environment
data_ge2 %>%
 group_by(ENV) %>%
 doo(~head(., 2))

# Genotype analysis for each environment using 'gafem()'
# variable PH
data_ge2 %>%
  group_by(ENV) %>%
  doo(~gafem(., GEN, REP, PH, verbose = FALSE))
# }

Run the code above in your browser using DataLab