diff --git a/DESCRIPTION b/DESCRIPTION index 3c02311..1b69829 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: statcheck Title: Extract Statistics from Articles and Recompute P-Values -Version: 1.4.0 -Date: 2020-04-30 +Version: 1.4.0-beta.2 +Date: 2021-03-17 Authors@R: c( person("Michele B.", "Nuijten", email = "m.b.nuijten@uvt.nl", role = c("aut", "cre")), diff --git a/R/regex.R b/R/regex.R index c9c96ce..f66c43b 100644 --- a/R/regex.R +++ b/R/regex.R @@ -31,8 +31,10 @@ RGX_TEST_DF <- paste0("(", RGX_T_DF, "|", RGX_R_DF, "|", RGX_Q_DF, "|", RGX_F_DF # test value # this is the same for every type of test +# the part "[^a-zA-Z\\d\\.]{0,3}" is to extract punctuation marks that could +# signal a weirdly encoded minus sign # note that impossible values such as r > 1 are excluded at a later stage -RGX_TEST_VALUE <- "[<>=]\\s?[^a-z\\d]{0,3}\\s?\\d*,?\\d*\\.?\\d+\\s?," +RGX_TEST_VALUE <- "[<>=]\\s?[^a-zA-Z\\d\\.]{0,3}\\s?\\d*,?\\d*\\.?\\d+\\s?," # p-values # this is the same for every type of test diff --git a/tests/testthat/test-extract-t-tests.R b/tests/testthat/test-extract-t-tests.R index a1462bb..a6e0dfe 100644 --- a/tests/testthat/test-extract-t-tests.R +++ b/tests/testthat/test-extract-t-tests.R @@ -46,6 +46,7 @@ test_that("variations in the t-statistic are retrieved from text", { txt2 <- "t(28) = 2,000.20, p = .03" txt3 <- "t(28) < 2.20, p = .03" txt4 <- "t(28) > 2.20, p = .03" + txt5 <- "t(28) = %^&2.20, p = .03" # read as -2.20 result <- statcheck(c(txt1, txt2, txt3, txt4), messages = FALSE) @@ -81,6 +82,7 @@ test_that("corrected degrees of freedom in t-tests are retrieved from text", { test_that("incorrect punctuation in t-tests are not retrieved from text", { txt1 <- "t(28) = 2.20; p = .03" txt2 <- "t[28] = 2.20, p = .03" + txt3 <- "t(28) = .2.20, p = .03" expect_output(statcheck(c(txt1, txt2), messages = FALSE), "did not find any results") }) diff --git a/tests/testthat/test-file-to-txt.R b/tests/testthat/test-file-to-txt.R index dfa8511..fa87745 100644 --- a/tests/testthat/test-file-to-txt.R +++ b/tests/testthat/test-file-to-txt.R @@ -5,7 +5,7 @@ context("Check if statistics from an article are correctly retrieved and parsed" # individual pdf files test_that("statistics from a pdf are correctly retrieved and parsed", { - pdf_file <- system.file("test_materials/NuijtenEtAl_2016_ReportingErrorsPsychology.pdf", + pdf_file <- system.file("test_materials/nuijten.pdf", package = "statcheck") result <- checkPDF(pdf_file, messages = FALSE) @@ -49,8 +49,8 @@ test_that("statistics from all pdfs in a folder are correctly retrieved and pars # individual html files test_that("statistics from a html are correctly retrieved and parsed", { - html_file <- system.file("test_materials/NuijtenEtAl_2016_ReportingErrorsPsychology.html", - package = "statcheck") + html_file <- system.file("test_materials/nuijten.html", + package = "statcheck") result <- checkHTML(html_file, messages = FALSE) result_1tailed <- checkHTML(html_file, messages = FALSE, OneTailedTxt = TRUE) @@ -63,7 +63,7 @@ test_that("statistics from a html are correctly retrieved and parsed", { # check errors expect_equal(result[[VAR_ERROR]], c(FALSE, FALSE, FALSE, TRUE, FALSE, TRUE)) expect_equal(result[[VAR_DEC_ERROR]], c(FALSE, FALSE, FALSE, TRUE, FALSE, TRUE)) - + # check errors with one-tailed test detection expect_equal(result_1tailed[[VAR_ERROR]], c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE)) expect_equal(result_1tailed[[VAR_DEC_ERROR]], c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE)) @@ -101,7 +101,7 @@ test_that("statistics from all pdfs and htmls in a folder are correctly retrieve dir <- system.file("test_materials", package = "statcheck") result <- checkdir(dir, subdir = FALSE, messages = FALSE) - + # extract 59 tests (6 from html and 53 from pdf) expect_equal(nrow(result), 59) })