When labeltext is a list, graph.pos cannot be set to any value above 2. That bug is due to incorrect calculation of the number of columns of the list.
The following code illustrate this problem:
Expected behavior: display three data columns (Author, Year, N), then, the forest plot, than a fourth data column (Weight).
Observed behavior: the following error is raised: "Error in forestplot.default(labeltext = pseudomat, mean = 1:2, lower = 0:1, :
The graph position must be between 1 and 2. You have provided the value '4'."
Current workaround
Sets the class of pseudomat to "data.frame" in order to override the behavior of ncol().
That hack is horrendous. The pseudomat object becomes a corrupted data.frame object, hybrid between a list of list and a real data.frame, tricking forestplot for its ncol() calculation.
Bug fix
This bug can be found on line 442 to 447 of the forestplot.R file. The code checks that the graph.pos is in the correct range, but uses NCOL(labeltext) rather than nc as the number of columns.
See pull request 81dc455
Test environment
Package: forestplot
Version: 1.9
Maintainer: Max Gordon max@gforge.se
Built: R 4.1.0; ; 2020-07-09 04:36:23 UTC; windows
R Version:
platform = x86_64-w64-mingw32
arch = x86_64
os = mingw32
system = x86_64, mingw32
status = Under development (unstable)
major = 4
minor = 1.0
year = 2020
month = 07
day = 11
svn rev = 78812
language = R
version.string = R Under development (unstable) (2020-07-11 r78812)
nickname = Unsuffered Consequences
Bug description
When labeltext is a list, graph.pos cannot be set to any value above 2. That bug is due to incorrect calculation of the number of columns of the list. The following code illustrate this problem:
Expected behavior: display three data columns (Author, Year, N), then, the forest plot, than a fourth data column (Weight). Observed behavior: the following error is raised: "Error in forestplot.default(labeltext = pseudomat, mean = 1:2, lower = 0:1, : The graph position must be between 1 and 2. You have provided the value '4'."
Current workaround
Sets the class of pseudomat to "data.frame" in order to override the behavior of ncol().
That hack is horrendous. The pseudomat object becomes a corrupted data.frame object, hybrid between a list of list and a real data.frame, tricking forestplot for its ncol() calculation.
Bug fix
This bug can be found on line 442 to 447 of the forestplot.R file. The code checks that the graph.pos is in the correct range, but uses NCOL(labeltext) rather than nc as the number of columns.
See pull request 81dc455
Test environment
Package: forestplot Version: 1.9 Maintainer: Max Gordon max@gforge.se Built: R 4.1.0; ; 2020-07-09 04:36:23 UTC; windows
R Version: platform = x86_64-w64-mingw32 arch = x86_64 os = mingw32 system = x86_64, mingw32 status = Under development (unstable) major = 4 minor = 1.0 year = 2020 month = 07 day = 11 svn rev = 78812 language = R version.string = R Under development (unstable) (2020-07-11 r78812) nickname = Unsuffered Consequences
Windows 10 x64 (build 17134)
Locale: LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252
Search Path: .GlobalEnv, package:forestplot, package:checkmate, package:magrittr, package:grid, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base