Description Usage Arguments Details Value Examples

This pseudo-generic function iterates a function on the subelements of a list of objects that have the same class and matching dimensions/names and reorganizes the result to match the structure of the replicates or a prototype template.

1 |

`x` |
( |

`FUN` |
( |

`proto` |
( |

`direct` |
( |

`...` |
arguments passed to |

The function is designed to unify/merge objects that result from the same function applied to different source data (e.g. the results of `subsample()`

). In its current form, the function supports `vectors`

(including one-dimensional `tables`

and `arrays`

), `matrix`

and `data.frame`

objects.

If `FUN`

is a `function`

, the output is `vector`

for `vector`

-like replicates, `matrix`

when `x`

is a `list`

of `matrix`

objects, and `data.frame`

s for `data.frame`

replicates. In case `FUN=NULL`

: if `x`

is a list of `vectors`

, the function will return a `matrix`

; an `array`

is returned, if `x`

is a `list`

of `matrix`

class obejcts; if `x`

is a list of `data.frame`

objects, the function returns a `data.frame`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ```
# basic example
vect <- rnorm(100)
# make 50 replicates
repl <- rep(list(vect), 50)
repmatch(repl, FUN=mean, direct="dim")
# named input
# two vectors
# a
a<- 1:10
names(a) <- letters[1:length(a)]
a[c(3,5,8)] <- NA
a <- a[!is.na(a)]
#b
b<- 10:1
names(b) <- letters[length(b):1]
b[c(1, 3,6, length(b))]<- NA
b <- b[!is.na(b)]
# list
x2 <- rep(c(list(a),list(b)), 3)
# simple match - falling through "dim" to "name" directive
repmatch(x2, FUN=NULL)
# prototyped
prot <- 1:10
names(prot) <-letters[1:10]
repmatch(x2, FUN=mean, proto=prot, na.rm=TRUE)
``` |

divDyn/r_package documentation built on July 9, 2019, 2:43 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.