Skip to contents

Add list as attributes to any object with or without overwrite.

Usage

AddAttr(var.any = NULL, attribute.lst = NULL, overwrite.bln = FALSE)

Arguments

var.any

<any>: an object to which attributes are to be added.

attribute.lst

<list>: a named list of new attributes.

overwrite.bln

<logical>: whether an overwrite is required on attributes with the same name.(Default FALSE)

Value

the object with new attributes.

Details

AddAttr

Examples

x <- 1:10
x
#>  [1]  1  2  3  4  5  6  7  8  9 10
attribute.lst = list(dim=c(2,5))
x <- AddAttr(x,attribute.lst)
x
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    3    5    7    9
#> [2,]    2    4    6    8   10
attribute.lst = list(dim=c(5,2))
x <- AddAttr(x,attribute.lst)
x
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    3    5    7    9
#> [2,]    2    4    6    8   10
x <- AddAttr(x,attribute.lst,overwrite.bln=TRUE)
x
#>      [,1] [,2]
#> [1,]    1    6
#> [2,]    2    7
#> [3,]    3    8
#> [4,]    4    9
#> [5,]    5   10