for (txt in text_found$text) {
if (grepl(sensitivity_power_regex, txt)) {
cat("You have performed a sensitivity power analysis.\n")
} else if (grepl(apriori_power_regex, txt)) {
cat("You performed an a-priori power analysis\n")
} else if (grepl(observed_power_regex, txt)) {
cat("Unless you know what you are doing, it is likely that you are reporting observed power, which is not recommended.\n")
} else if (grepl(compromise_power_regex, txt)) {
cat("Compromise power analysis are rarely used, but good for you.\n")
} else
cat("We caught a description of a power analysis. Please consider labeling it as 'sensitivity', 'a priori', or 'compromise. Because most often this will refer to an a-priori power analysis, we will treat it as such.\n")
}
Find power analysis
The feedback needs to be changed to something useful, but the detection should work.
sensitivity_power_regex <- "(\bsensitivity analysis\b(.{0,240})(?:power|sample|detect|participants)|(?:power|sample|to detect|participants)(.{0,240})(\bsensitivity analysis\b)|\bsensitivity power analysis\b)" compromise_power_regex <- "(\bcompromise power analysis\b|\bcompromise analysis\b)" observed_power_regex <- "(\bobserved power\b|\bpost[ -]hoc power\b|\bretrospective power\b|\b(?:achieved(?:\s+\w+){0,2}\s+power)\b)" apriori_power_regex <- "\ba[ -]priori power analysis\b" power_regex <- "[Gg][ *]?Power|\bpower calculation\b|\bpower computation\b|\bpower\b.{0,12}\banalysis\b|\banalysis\b.{0,12}\bpower\b|\b?:\d+(?:\.\d+)?% power\b|\bpower of \.\d+\b" power_total_regex <- paste0("(",sensitivity_power_regex,"|",compromise_power_regex,"|",observed_power_regex,"|",apriori_power_regex,"|", power_regex, ")") text_found <- search_text(xml, power_total_regex) text_found$text
for (txt in text_found$text) { if (grepl(sensitivity_power_regex, txt)) { cat("You have performed a sensitivity power analysis.\n") } else if (grepl(apriori_power_regex, txt)) { cat("You performed an a-priori power analysis\n") } else if (grepl(observed_power_regex, txt)) { cat("Unless you know what you are doing, it is likely that you are reporting observed power, which is not recommended.\n") } else if (grepl(compromise_power_regex, txt)) { cat("Compromise power analysis are rarely used, but good for you.\n") } else cat("We caught a description of a power analysis. Please consider labeling it as 'sensitivity', 'a priori', or 'compromise. Because most often this will refer to an a-priori power analysis, we will treat it as such.\n") }