From 073d67ce609b84dcda650deff5bb41e9ce24ca91 Mon Sep 17 00:00:00 2001 From: Alan Haynes Date: Tue, 8 Oct 2019 11:43:16 +0200 Subject: [PATCH 1/6] use length.out should improve speed for larger datasets --- R/build_limits_lookup.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/build_limits_lookup.R b/R/build_limits_lookup.R index 735f6f0..fed32d7 100644 --- a/R/build_limits_lookup.R +++ b/R/build_limits_lookup.R @@ -31,7 +31,7 @@ build_limits_lookup<-function(min_preds, max_preds, min_ratio, max_ratio, Poisso # general limits + Tau2 limits table set.seed(1) - number.seq <- c(seq(0.1, 10, 0.1), seq(11.0, max_preds, 1)) + number.seq <- c(seq(0.1, 10, 0.1), seq(11.0, max_preds, length.out = 1000)) dfCI <- data.frame( number.seq, ll95 = multiplier * ((qchisq(0.975, 2 * number.seq, lower.tail = FALSE) / 2) / number.seq), @@ -42,7 +42,7 @@ build_limits_lookup<-function(min_preds, max_preds, min_ratio, max_ratio, Poisso } else if (method == "SHMI") { # general limits + Tau2 limits table set.seed(1) - number.seq <- c(seq(0.1, 10, 0.1), seq(11.0, max_preds, 1)) + number.seq <- c(seq(0.1, 10, 0.1), seq(11.0, max_preds, length.out = 1000)) dfCI <- data.frame( number.seq, ll95 = multiplier * ((qchisq(0.975, 2 * number.seq, lower.tail = FALSE) / 2) / number.seq), @@ -56,7 +56,7 @@ build_limits_lookup<-function(min_preds, max_preds, min_ratio, max_ratio, Poisso ) } else if (method == "CQC") { set.seed(1) - number.seq <- seq(1, ceiling(as.numeric(max_preds)), 1) + number.seq <- seq(1, ceiling(as.numeric(max_preds)), length.out = 1000) dfCI <- data.frame( number.seq, ll95 = multiplier * ((qchisq(0.975, 2 * number.seq, lower.tail = FALSE) / 2) / number.seq), From db467b5590faddc8a2c424ccc623e505dc07fa4d Mon Sep 17 00:00:00 2001 From: Chris Mainey Date: Wed, 9 Oct 2019 09:28:23 +0100 Subject: [PATCH 2/6] Final prerelease of 0.2.1 --- .Rbuildignore | 1 + cran-comments.md | 2 +- testsers.R | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 testsers.R diff --git a/.Rbuildignore b/.Rbuildignore index 5e98d21..3bb150c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,3 +14,4 @@ cran-comments.md ^pkgdown$ ^CRAN-RELEASE$ ^README\.Rmd$ +testers.R \ No newline at end of file diff --git a/cran-comments.md b/cran-comments.md index f6c0b6a..b662b96 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -16,7 +16,7 @@ This is a second release of a package wrapper for ggplot2 to draw funnel plots f There were no ERRORs or WARNINGs. NOTES on win-builder and r-hub about possibly invalid links. -These refer to DOIs in references in the vignette. I've manually tested all links and they are valid. +These refer to DOIs for references in the vignette. I've manually tested all links and they are valid. Further note on win-builder and some r-hub builds about a CRAN reference not being in canonical form. This has been changed to use https as suggested. diff --git a/testsers.R b/testsers.R new file mode 100644 index 0000000..0da8bdc --- /dev/null +++ b/testsers.R @@ -0,0 +1,41 @@ +a<-2 +b<-2 + +if(a==1 | a==2 & b==1){ + print("yes") +} else print("no") + + +number.seq<-seq(5,50,5) + +t <- 0.5 + +t * ((qchisq(0.975, 2 * number.seq, lower.tail = FALSE) / 2) / number.seq) + + + +funnel_plot(numerator = c(8, 15,18,8,12, 22), denominator= c(12, 21, 26,15,20, 30), OD_adjust=FALSE, + group = factor(c("a","b","c", "d","e","f")), type = "pr", return_elements = "plot") +) + + + +mod_plot<-data.frame(numerator = c(8, 15,18,8,12, 22), denominator= c(12, 21, 26,15,20, 30), + group = factor(c("a","b","c", "d","e","f"))) + +mod_plot_agg<-aggregate_func(mod_plot) + +aggregate_func<- function(mod_plot) { + + mod_plot_agg <- mod_plot %>% + dplyr::group_by(.data$group) %>% + dplyr::summarise( + numerator = as.numeric(sum(.data$numerator)), + denominator = as.numeric(sum(.data$denominator)), + ratio = .data$numerator / .data$denominator + ) + + return(mod_plot_agg) + +} + From 5713e7937ce4f245af379889e2d52fc9167b9c04 Mon Sep 17 00:00:00 2001 From: Alan Haynes Date: Wed, 9 Oct 2019 10:37:29 +0200 Subject: [PATCH 3/6] fix test --- tests/testthat/test-build_limits_lookup.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-build_limits_lookup.R b/tests/testthat/test-build_limits_lookup.R index 21f2b1e..140de63 100644 --- a/tests/testthat/test-build_limits_lookup.R +++ b/tests/testthat/test-build_limits_lookup.R @@ -5,7 +5,7 @@ test_that("`build limits funcion` works with input and returns expected data.fra expect_s3_class(z, "data.frame") expect_length(z, 9) - expect_length(z$number.seq, 340) + expect_length(z$number.seq, 1100) #expect_equal(round(b$rr,6), c(1.069652, 1.071795, 1.022727)) -}) \ No newline at end of file +}) From f00f17934a5aa9f96cb12e59430595de65d5d277 Mon Sep 17 00:00:00 2001 From: Chris Mainey Date: Wed, 9 Oct 2019 15:58:36 +0100 Subject: [PATCH 4/6] small error in buildignore --- .Rbuildignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Rbuildignore b/.Rbuildignore index 3bb150c..29cb0bc 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,4 +14,4 @@ cran-comments.md ^pkgdown$ ^CRAN-RELEASE$ ^README\.Rmd$ -testers.R \ No newline at end of file +testers.R$ \ No newline at end of file From c9029f5906594f5310ca21f59a29a596e5857369 Mon Sep 17 00:00:00 2001 From: Chris Mainey Date: Fri, 11 Oct 2019 10:58:19 +0100 Subject: [PATCH 5/6] bump dev version number --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index bfc3e63..18a0ee7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: FunnelPlotR Type: Package Title: Funnel Plots for Indirectly-Standardised Ratios -Version: 0.2.1 +Version: 0.2.2.999 Authors@R: c( person("Chris", "Mainey", ,"chris.mainey@uhb.nhs.uk", role= c("aut", "cre"), comment = c(ORCID ="0000-0002-3018-6171") From 784dadf9a0403201e7ca49ac15d51103c08b9d6f Mon Sep 17 00:00:00 2001 From: Chris Mainey Date: Thu, 14 Nov 2019 16:39:39 +0000 Subject: [PATCH 6/6] Bug fix when max preds was integer but by argument of seq_along was double --- R/build_limits_lookup.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/build_limits_lookup.R b/R/build_limits_lookup.R index fed32d7..bff1934 100644 --- a/R/build_limits_lookup.R +++ b/R/build_limits_lookup.R @@ -31,7 +31,7 @@ build_limits_lookup<-function(min_preds, max_preds, min_ratio, max_ratio, Poisso # general limits + Tau2 limits table set.seed(1) - number.seq <- c(seq(0.1, 10, 0.1), seq(11.0, max_preds, length.out = 1000)) + number.seq <- c(seq(0.1, 10.0, 0.1), seq(11.0, as.numeric(max_preds), length.out = 1000)) dfCI <- data.frame( number.seq, ll95 = multiplier * ((qchisq(0.975, 2 * number.seq, lower.tail = FALSE) / 2) / number.seq), @@ -42,7 +42,7 @@ build_limits_lookup<-function(min_preds, max_preds, min_ratio, max_ratio, Poisso } else if (method == "SHMI") { # general limits + Tau2 limits table set.seed(1) - number.seq <- c(seq(0.1, 10, 0.1), seq(11.0, max_preds, length.out = 1000)) + number.seq <- c(seq(0.1, 10.0, 0.1), seq(11.0, as.numeric(max_preds), length.out = 1000)) dfCI <- data.frame( number.seq, ll95 = multiplier * ((qchisq(0.975, 2 * number.seq, lower.tail = FALSE) / 2) / number.seq),