Skip to content

Commit

Permalink
Merge pull request #40 from MicheleNuijten/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
MicheleNuijten authored Mar 17, 2021
2 parents 49967fb + 68ca348 commit e078771
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
4 changes: 3 additions & 1 deletion R/regex.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-extract-t-tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
})
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-file-to-txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit e078771

Please sign in to comment.