Skip to content

Commit

Permalink
Made the append argument more flexible in to.long().
Browse files Browse the repository at this point in the history
  • Loading branch information
wviechtb committed Aug 30, 2023
1 parent 942bda6 commit 27cfafa
Show file tree
Hide file tree
Showing 123 changed files with 419 additions and 193 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: metafor
Version: 4.3-14
Date: 2023-08-29
Version: 4.3-15
Date: 2023-08-30
Title: Meta-Analysis Package for R
Authors@R: person(given = "Wolfgang", family = "Viechtbauer", role = c("aut","cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-3463-4063"))
Depends: R (>= 4.0.0), methods, Matrix, metadat, numDeriv
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# metafor 4.3-14 (2023-08-29)
# metafor 4.3-15 (2023-08-30)

- added `getmfopt()` and `setmfopt()` functions for getting and setting package options and made some of the options more flexible

Expand Down Expand Up @@ -26,6 +26,8 @@

- made the `legend` argument more flexible in `funnel()`

- made the `append` argument more flexible in `to.long()`

- added a few more transformation functions

- small bug fixes
Expand Down
88 changes: 56 additions & 32 deletions R/to.long.r
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
data <- data.frame(data)
}

doappend <- FALSE

if (has.data && is.logical(append) && isTRUE(append)) {
doappend <- TRUE
appendvars <- seq_len(ncol(data))
}

if (has.data && is.numeric(append)) {
doappend <- TRUE
append <- unique(round(append))
append <- append[which(append >= 1)]
append <- append[which(append <= ncol(data))]
append <- c(na.omit(append))
appendvars <- append
}

if (has.data && is.character(append)) {
doappend <- TRUE
append <- unique(append)
append <- pmatch(append, colnames(data))
append <- c(na.omit(append))
appendvars <- append
}

mf <- match.call()

### get slab and subset arguments (will be NULL when unspecified)
Expand Down Expand Up @@ -700,8 +724,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[2]] <- factor(dat[[2]], levels=c(2,1))
dat[[3]] <- factor(dat[[3]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=4L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=4L),appendvars,drop=FALSE], dat)

} else {

Expand All @@ -724,8 +748,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[1]] <- factor(dat[[1]])
dat[[2]] <- factor(dat[[2]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=2L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=2L),appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -790,8 +814,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[2]] <- factor(dat[[2]], levels=c(2,1))
dat[[3]] <- factor(dat[[3]], levels=c(2,1))

if (has.data && append)
dat <- data.frame(data[rep(seq_len(k), each=4L),], dat)
if (doappend)
dat <- data.frame(data[rep(seq_len(k), each=4L),appendvars,drop=FALSE], dat)

} else {

Expand All @@ -814,8 +838,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[1]] <- factor(dat[[1]])
dat[[2]] <- factor(dat[[2]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=2L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=2L),appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -880,8 +904,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[2]] <- factor(dat[[2]], levels=c(2,1))
dat[[3]] <- factor(dat[[3]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=4L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=4L),appendvars,drop=FALSE], dat)

} else {

Expand All @@ -904,8 +928,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[1]] <- factor(dat[[1]])
dat[[2]] <- factor(dat[[2]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=2L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=2L),appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -965,8 +989,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[1]] <- factor(dat[[1]])
dat[[2]] <- factor(dat[[2]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=2L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=2L),appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -1027,8 +1051,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[1]] <- factor(dat[[1]])
dat[[2]] <- factor(dat[[2]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=2L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=2L),appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -1082,8 +1106,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,

dat[[1]] <- factor(dat[[1]])

if (has.data && append)
dat <- cbind(data, dat)
if (doappend)
dat <- cbind(data[,appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -1142,8 +1166,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,
dat[[1]] <- factor(dat[[1]])
dat[[2]] <- factor(dat[[2]], levels=c(2,1))

if (has.data && append)
dat <- cbind(data[rep(seq_len(k), each=2L),], dat)
if (doappend)
dat <- cbind(data[rep(seq_len(k), each=2L),appendvars,drop=FALSE], dat)

} else {

Expand All @@ -1164,8 +1188,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,

dat[[1]] <- factor(dat[[1]])

if (has.data && append)
dat <- cbind(data, dat)
if (doappend)
dat <- cbind(data[,appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -1221,8 +1245,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,

dat[[1]] <- factor(dat[[1]])

if (has.data && append)
dat <- cbind(data, dat)
if (doappend)
dat <- cbind(data[,appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -1278,8 +1302,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,

dat[[1]] <- factor(dat[[1]])

if (has.data && append)
dat <- cbind(data, dat)
if (doappend)
dat <- cbind(data[,appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -1348,8 +1372,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,

dat[[1]] <- factor(dat[[1]])

if (has.data && append)
dat <- cbind(data, dat)
if (doappend)
dat <- cbind(data[,appendvars,drop=FALSE], dat)

} else {

Expand All @@ -1371,8 +1395,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,

dat[[1]] <- factor(dat[[1]])

if (has.data && append)
dat <- cbind(data, dat)
if (doappend)
dat <- cbind(data[,appendvars,drop=FALSE], dat)

}

Expand Down Expand Up @@ -1430,8 +1454,8 @@ data, slab, subset, add=1/2, to="none", drop00=FALSE, vlong=FALSE, append=TRUE,

dat[[1]] <- factor(dat[[1]])

if (has.data && append)
dat <- data.frame(data, dat)
if (doappend)
dat <- data.frame(data[,appendvars,drop=FALSE], dat)

}

Expand Down
2 changes: 1 addition & 1 deletion R/zzz.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.onAttach <- function(libname, pkgname) {

ver <- "4.3-14"
ver <- "4.3-15"

loadmsg <- paste0("\nLoading the 'metafor' package (version ", ver, "). For an\nintroduction to the package please type: help(metafor)\n")

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metafor: A Meta-Analysis Package for R
[![R build status](https://github.com/wviechtb/metafor/workflows/R-CMD-check/badge.svg)](https://github.com/wviechtb/metafor/actions)
[![Code Coverage](https://codecov.io/gh/wviechtb/metafor/branch/master/graph/badge.svg)](https://app.codecov.io/gh/wviechtb/metafor)
[![CRAN Version](https://www.r-pkg.org/badges/version/metafor)](https://cran.r-project.org/package=metafor)
[![devel Version](https://img.shields.io/badge/devel-4.3--14-brightgreen.svg)](https://www.metafor-project.org/doku.php/installation#development_version)
[![devel Version](https://img.shields.io/badge/devel-4.3--15-brightgreen.svg)](https://www.metafor-project.org/doku.php/installation#development_version)
[![Monthly Downloads](https://cranlogs.r-pkg.org/badges/metafor)](https://cranlogs.r-pkg.org/badges/metafor)
[![Total Downloads](https://cranlogs.r-pkg.org/badges/grand-total/metafor)](https://cranlogs.r-pkg.org/badges/grand-total/metafor)

Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/ISSUE_TEMPLATE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/pkgdown/diagram.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pkgdown: 2.0.7
pkgdown_sha: ~
articles:
diagram: pkgdown/diagram.html
last_built: 2023-08-29T19:59Z
last_built: 2023-08-30T16:26Z
urls:
reference: https://wviechtb.github.io/metafor/reference
article: https://wviechtb.github.io/metafor/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/addpoly.default.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/addpoly.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/addpoly.predict.rma.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/addpoly.rma.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/aggregate.escalc.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/anova.rma.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 27cfafa

Please sign in to comment.