Skip to content

Commit

Permalink
CRAN updates (#26)
Browse files Browse the repository at this point in the history
* remove imports handled by BayesTools and suppress start-up message

* update unit tests

* update ggplot2 aes_string
  • Loading branch information
FBartos authored Mar 13, 2023
1 parent 3a2995c commit 0bd253e
Show file tree
Hide file tree
Showing 145 changed files with 1,475 additions and 1,442 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ RoBMA.Rcheck
.Rprofile
/doc/
/Meta/
models/MetaRegression/*
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RoBMA
Title: Robust Bayesian Meta-Analyses
Version: 2.3.1
Version: 2.3.2
Maintainer: František Bartoš <[email protected]>
Authors@R: c(
person("František", "Bartoš", role = c("aut", "cre"),
Expand Down Expand Up @@ -34,24 +34,22 @@ License: GPL-3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.0
RoxygenNote: 7.2.3
SystemRequirements: JAGS >= 4.3.1 (https://mcmc-jags.sourceforge.io/)
NeedsCompilation: yes
Depends:
R (>= 4.0.0)
Imports:
BayesTools (>= 0.2.0),
runjags,
bridgesampling,
rjags,
coda,
psych,
stats,
graphics,
extraDistr,
mvtnorm,
scales,
Rdpack,
rlang,
ggplot2
Suggests:
parallel,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ importFrom(BayesTools,is.prior.none)
importFrom(BayesTools,is.prior.point)
importFrom(BayesTools,is.prior.simple)
importFrom(BayesTools,is.prior.weightfunction)
importFrom(Rdpack,reprompt)
importFrom(rlang,.data)
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## version 2.3.2
### Fixes
- suppressing start-up message
- cleaning up imports

## version 2.3.1
### Fixes
- fixing weighted meta-analysis parameterization
Expand Down
2 changes: 2 additions & 0 deletions R/RoBMA-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@
##'
##' @references \insertAllCited{}
##' @importFrom BayesTools is.prior is.prior.none is.prior.point is.prior.simple is.prior.PET is.prior.PEESE is.prior.weightfunction
##' @importFrom Rdpack reprompt
##' @importFrom rlang .data
"_PACKAGE"

34 changes: 27 additions & 7 deletions R/diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,17 @@ diagnostics <- function(fit, parameter, type, plot_type = "base", show_models =

}else if(plot_type == "ggplot"){

graph <- ggplot2::ggplot(plot_data$samp, ggplot2::aes_string(x = "iteration", y = "value", color = "chain")) +
graph <- ggplot2::ggplot(
data = data.frame(
x = plot_data$samp$iteration,
y = plot_data$samp$value,
color = plot_data$samp$chain),
mapping = ggplot2::aes(
x = .data[["x"]],
y = .data[["y"]],
color = .data[["color"]])) +
ggplot2::geom_path() +
ggplot2::scale_color_manual(values = .diagnostics_color(plot_data$nchains))
ggplot2::scale_color_manual(name = "chain", values = .diagnostics_color(plot_data$nchains))
temp_x_range <- range(plot_data$samp$iteration)
temp_y_range <- range(plot_data$samp$value)
graph <- graph + ggplot2::scale_x_continuous(
Expand Down Expand Up @@ -283,9 +291,15 @@ diagnostics <- function(fit, parameter, type, plot_type = "base", show_models =

}else if(plot_type == "ggplot"){

graph <- ggplot2::ggplot(plot_data$samp, ggplot2::aes_string(x = "value")) +
ggplot2::geom_density(mapping = ggplot2::aes_string(fill = "chain"), color = "black", alpha = .5) +
ggplot2::scale_fill_manual(values = .diagnostics_color(plot_data$nchains))
graph <- ggplot2::ggplot(
data = data.frame(
x = plot_data$samp$value,
fill = plot_data$samp$chain),
mapping = ggplot2::aes(
x = .data[["x"]],
fill = .data[["fill"]])) +
ggplot2::geom_density(color = "black", alpha = .5) +
ggplot2::scale_fill_manual(name = "chain", values = .diagnostics_color(plot_data$nchains))
temp_y_max <- max(ggplot2::ggplot_build(graph)$data[[1]]$density)
temp_x_range <- if(par == "omega") c(0, 1) else range(plot_data$samp$value)
graph <- graph + ggplot2::scale_y_continuous(
Expand Down Expand Up @@ -339,8 +353,14 @@ diagnostics <- function(fit, parameter, type, plot_type = "base", show_models =
graph <- NULL

}else if(plot_type == "ggplot"){
graph <- ggplot2::ggplot(ac_dat, ggplot2::aes_string(x = "lag", y = "ac")) +
ggplot2::geom_bar(size = .5, color = "black", fill = "#B2001D", position = "dodge", stat = "summary", fun = "mean") +
graph <- ggplot2::ggplot(
data = data.frame(
x = ac_dat$lag,
y = ac_dat$ac),
mapping = ggplot2::aes(
x = .data[["x"]],
y = .data[["y"]])) +
ggplot2::geom_bar(linewidth = .5, color = "black", fill = "#B2001D", position = "dodge", stat = "summary", fun = "mean") +
ggplot2::scale_y_continuous(breaks = seq(0, 1, 0.25)) +
ggplot2::labs(x = "Lag", y = "Avg. autocorrelation")
if(!is.null(title)){
Expand Down
6 changes: 4 additions & 2 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ RoBMA.get_option <- function(name){
return(eval(RoBMA.private[[name]]))
}


# export the function directly to suppress import warnings
.runjags__findjags <- function() runjags::findjags()

# adapted from the runjags package version 2.2.0
RoBMA.private <- new.env()
# Use 'expression' for functions to avoid having to evaluate before the package is fully loaded:
assign("defaultoptions", list(
jagspath = expression(runjags::findjags()),
jagspath = expression(.runjags__findjags()),
envir = RoBMA.private))

assign("options", RoBMA.private$defaultoptions, envir = RoBMA.private)
Expand Down Expand Up @@ -86,6 +87,7 @@ assign("max_cores", parallel::detectCores(logical = TRUE) - 1, envir = Ro
"2.2.3" = c("0.2.3", "999.999.999"),
"2.3.0" = c("0.2.3", "999.999.999"),
"2.3.1" = c("0.2.3", "999.999.999"),
"2.3.2" = c("0.2.3", "999.999.999"),
stop("New RoBMA version needs to be defined in '.check_BayesTools' function!")
)

Expand Down
5 changes: 4 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
module_location <- NULL
warning('The RoBMA module could not be loaded.', call. = FALSE)
}else{
rjags::load.module("RoBMA", path = module_location)
rjags::load.module("RoBMA", path = module_location, quiet = TRUE)
if(!"RoBMA" %in% rjags::list.modules()){
warning('The RoBMA module could not be loaded.', call. = FALSE)
}
}

RoBMA.private$module_location <- module_location
Expand Down
4 changes: 2 additions & 2 deletions man/RoBMA.Rd

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

4 changes: 2 additions & 2 deletions man/check_setup.Rd

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

10 changes: 5 additions & 5 deletions tests/testthat/_snaps/6-plots/ggplot-forest1-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/6-plots/ggplot-forest1-10.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/6-plots/ggplot-forest1-11.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/6-plots/ggplot-forest1-12.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0bd253e

Please sign in to comment.