MDapply: Apply Function to Elements of a MDlist

Description Usage Arguments Value Examples

Description

A convienence wrapper for MDget and optionally MDassign. For more complicated needs (i.e. working with more than one variable or pieces of a variable) use MDget to retrieve variable(s) and then lapply with select functions. Finally, reassign with MDassign.

Usage

1
  MDapply(meta.obj, var, FUN, newvar = NULL)

Arguments

meta.obj

An MDlist (an object from read.MD).

var

A length one character vector of the variable name to grab.

FUN

A function that takes a single argument.

newvar

A length one character vector of the variable name to assign to.

Value

Returns a metaDAT list object with the newly assigned values.

Examples

1
2
3
4
5
6
path <- system.file("extdata/bibTest.bib", package = "metaDAT")
dat <- read.MD(path)
dat <- MDapply(dat, "correlation_triangle", MDlist2matrix, "cor_mats")
MDapply(dat, "correlation_triangle", MDlist2matrix)
mean2 <- function(x) mean(unlist(x), na.rm = TRUE)
MDapply(dat, "cor_mats", mean2)

trinker/metaDAT documentation built on May 31, 2019, 8:52 p.m.