Skip to content

Commit

Permalink
Merge pull request #58 from MicheleNuijten/bug-jepg-article
Browse files Browse the repository at this point in the history
bug fix: don't extract multiple comparisons
  • Loading branch information
MicheleNuijten authored Dec 20, 2022
2 parents 8c21c68 + 7691ec2 commit e5d7c51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 22 additions & 1 deletion R/extract_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,29 @@ extract_stats <- function(txt, stat){

test <- extract_test_stats(raw = nhst_raw[i])

test_stats <- rbind(test_stats, test)
# ignore any cases with more than 1 test comparison (e.g., z >= 2)
if(nrow(test) > 1){
test <- data.frame(test_comp = NA,
test_value = NA,
test_dec = NA)
}

test_stats <- rbind(test_stats, test)

# extract p-comparison and p-value

p <- extract_p_value(raw = nhst_raw[i])

# ignore any cases with more than 1 test comparison (e.g., p >= .01)
if(nrow(p) > 1){
p <- data.frame(p_comp = NA,
p_value = NA,
p_dec = NA)
}

pvals <- rbind(pvals, p)


}

# create final data frame ------------------------------------------------------
Expand Down Expand Up @@ -122,6 +137,12 @@ extract_stats <- function(txt, stat){
# and would otherwise break down
nhst_parsed <- nhst_parsed[!is.na(nhst_parsed$Value), ]

# remove missing test comparisons or p comparisons
# reason: these are marked as NA in cases where multiple comparisons were
# reported. E.g., t(23) >= ..., p >= ...
nhst_parsed <- nhst_parsed[!is.na(nhst_parsed$Test.Comparison) &
!is.na(nhst_parsed$Reported.Comparison), ]

# only return selected stats
# to that end, rename test-types to match argument stat
types <- as.vector(nhst_parsed$Statistic)
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-extract-t-tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,10 @@ test_that("t-values with a weird minus sign and a space do not result in errors"
expect_output(statcheck(txt1, messages = FALSE), "did not find any results")
})

# multiple comparison signs
test_that("t-values with multiple comparison signs are not retrieved", {
txt1 <- "t(38) >= 2.25, p = .03"
txt2 <- "t(38) = 2.25, p >= .03"

expect_output(statcheck(c(txt1, txt2), messages = FALSE), "did not find any results")
})

0 comments on commit e5d7c51

Please sign in to comment.