Skip to content

Commit

Permalink
Add tidyr soft dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
remlapmot committed Jul 6, 2024
1 parent 767958c commit 78c5483
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ Suggests:
MendelianRandomization,
MRInstruments,
randomForest,
testthat
testthat,
tidyr
VignetteBuilder:
knitr
Remotes:
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Improve permissions in GitHub Actions workflows
* Bump minimum required version of **ieugwasr** to 1.0.1
* Made some amends to the code to bring it more in line with **lintr** recommendations
* Added omitted **tidyr** soft dependency

# TwoSampleMR v0.6.5

Expand Down
9 changes: 8 additions & 1 deletion R/add_rsq.r
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ get_r_from_pn_less_accurate <- function(p, n)

test_r_from_pn <- function()
{
if (!requireNamespace("tidyr", quietly = TRUE)) {
stop(
"Package \"tidyr\" must be installed to use this function.",
call. = FALSE
)
}

param <- expand.grid(
n = c(10, 100, 1000, 10000, 100000),
rsq = 10^seq(-4,-0.5, length.out=30)
Expand All @@ -125,7 +132,7 @@ test_r_from_pn <- function()
param$rsq2[i] <- get_r_from_pn(param$pval[i], param$n[i])^2
}

param <- gather(param, key=out, value=value, rsq1, rsq2)
param <- tidyr::gather(param, key=out, value=value, rsq1, rsq2)

p <- ggplot2::ggplot(param, ggplot2::aes(x=rsq_emp, value)) +
ggplot2::geom_abline(slope=1, linetype="dotted") +
Expand Down

0 comments on commit 78c5483

Please sign in to comment.