named_out: Names and returns object inside nested apply functions

Description Usage Arguments Details Value Examples

Description

This little function assigns a name to an object created by an inner apply function and returns it

Usage

1
named_out(ret, nm)

Arguments

ret

Object

nm

Name to assign to object

Details

The entire purpose of this function is simply to save a line when writing nested apply functions so that names can be assigned to object and returned without taking up needless space

Value

Named object out of loop

Examples

1
2
3
4
5
6
7
8
ab <- list("a" = c(1:10), "b" = c(11:20))
d <- sample(-5:5, size = 10, replace = TRUE)
lapply(ab$a, function(x) {
  o <- lapply(d, function(j) {
    x * ab$b * d
  })  
  named_out(o, paste("a", x, "b", gsub("-", "neg", d), sep = "")) 
})

PrincetonUniversity/lmisc documentation built on May 8, 2019, 3:23 a.m.