cAppend: Custom Inserting/Appending Into R Objects

Description Usage Arguments Details Value Examples

View source: R/customSorting.R

Description

This is a generalization of the R base package function "append".

Usage

1
2
3
4
5
6
7
cAppend(x, values, ...)

## Default S3 method:
cAppend(x, values, ...)

## S3 method for class 'data.frame'
cAppend(x, values, ...)

Arguments

x

The R object, such that the values are to be inserted/appended to.

values

List. The values to be included in the modified R object.

...

Dots passed.

Details

Insert/append elements. If the elements are part of a collection, then the length of all elements of the list must be the same. Currently, (at this time), supported, are R objects: "list", "vector" and class "data.frame". "values" should be passed as a list. The new collection item names are taken from the List item names.

The type conversion function "ValuesFunction" can (if supported by the S3 method), transform the data: ValueFunction = "Rfunction(value)".

Value

Modified R Object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
cAppend(letters, list(c("zz","yy")),
  ValueFunction = "toupper(value)"
)
cAppend(iris[1:2,],
  list(END = c("zz","yy"), BEGIN = c("aa","bb")),
  ValueFunction = "toupper(value)", after = 3
  )
cAppend(as.list(iris[1:2,]),
  list(END = c("zz","yy"), BEGIN = c("aa","bb")),
  ValueFunction = "toupper(value)", after = 3
  )

## End(Not run)

AndreMikulec/econModel documentation built on June 30, 2021, 9:48 a.m.