PreserveAttr: PreserveAttr

Description Usage Arguments Value Examples

View source: R/extra.R

Description

This function returns a function that retains the desired attribute of its first argument.

Usage

1
PreserveAttr(.which)

Arguments

.which

name of attribute to preserve from first argument of returned function

Value

A new function which accepts the function to be applied as its first argument, and its arguments follow. The first of these arguments will be used to obtain the attribute to be copied to the returned object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
label <- sprintf("V%d",seq(3))

id.float <- setNames(seq(.1,.3,.1),label)

var.1 <- setNames(1:3,label)
attr(var.1,"id") <- id.float

var.2 <- setNames(4:6,label)
attr(var.2,"id") <- id.float

PreserveAttr("id")(rbind,var.1,var.2)

stakahama/Rfunctools documentation built on June 8, 2021, 10:25 p.m.