by-lapply.RdThis function is a wrapper for calling lapply on the list resulting from first calling splitBy.
lapply_by(data, formula, FUN, ...)
lapplyBy(formula, data = parent.frame(), FUN, ...)
sapply_by(data, formula, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
sapplyBy(
  formula,
  data = parent.frame(),
  FUN,
  ...,
  simplify = TRUE,
  USE.NAMES = TRUE
)A dataframe.
A formula describing how data should be split.
A function to be applied to each element in the split list, see 'Examples' below.
optional arguments to FUN.
Same as for sapply
Same as for sapply
A list.
fun <- function(x) range(x$uptake)
lapplyBy(~Treatment + Type, data=CO2, FUN=fun)
#> $`nonchilled|Quebec`
#> [1] 13.6 45.5
#> 
#> $`chilled|Quebec`
#> [1]  9.3 42.4
#> 
#> $`nonchilled|Mississippi`
#> [1] 10.6 35.5
#> 
#> $`chilled|Mississippi`
#> [1]  7.7 22.2
#> 
sapplyBy(~Treatment + Type, data=CO2, FUN=fun)
#>      nonchilled|Quebec chilled|Quebec nonchilled|Mississippi
#> [1,]              13.6            9.3                   10.6
#> [2,]              45.5           42.4                   35.5
#>      chilled|Mississippi
#> [1,]                 7.7
#> [2,]                22.2
# Same as
lapply(splitBy(~Treatment + Type, data=CO2), FUN=fun)
#> $`nonchilled|Quebec`
#> [1] 13.6 45.5
#> 
#> $`chilled|Quebec`
#> [1]  9.3 42.4
#> 
#> $`nonchilled|Mississippi`
#> [1] 10.6 35.5
#> 
#> $`chilled|Mississippi`
#> [1]  7.7 22.2
#>