Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small stylistic improvements #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/calc_APA_factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ calc_APA_factor <- function(pRes, Res){

APAfactor <-
round(as.numeric(apply(Res, 1, function(x)
APA[which(names(APA) == x["Source"])])), 2)
APA[names(APA) == x["Source"]])), 2)

return(APAfactor)

Expand Down
6 changes: 3 additions & 3 deletions R/checkHTMLdir.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ checkHTMLdir <- function(dir,
dir <- tcltk::tk_choose.dir()
}

if (extension == TRUE) {
if (extension) {
pat = ".html|.htm"
}

if (extension == FALSE) {
if (!extension) {
pat = ""
}

Expand All @@ -31,7 +31,7 @@ checkHTMLdir <- function(dir,
message("Importing HTML files...")
pb <- utils::txtProgressBar(max = length(files), style = 3)

for (i in 1:length(files)) {
for (i in seq_along(files)) {
txts[i] <- getHTML(files[i])
utils::setTxtProgressBar(pb, i)
}
Expand Down
2 changes: 1 addition & 1 deletion R/checkPDFdir.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ checkPDFdir <-
message("Importing PDF files...")
pb <- utils::txtProgressBar(max = length(files), style = 3)

for (i in 1:length(files)){
for (i in seq_along(files)){
txts[i] <- getPDF(files[i])
utils::setTxtProgressBar(pb, i)
}
Expand Down
8 changes: 4 additions & 4 deletions R/checkdir.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ checkdir <-
if (htmls)
htmlres <- checkHTMLdir(dir, subdir, ...)

if (pdfs & htmls) {
if (pdfs && htmls) {
if (!is.null(pdfres) & !is.null(htmlres))
Res <- rbind(pdfres, htmlres)
else
stop("statcheck did not find any results")

} else
if (pdfs & !htmls) {
if (pdfs && !htmls) {
if (!is.null(pdfres))
Res <- pdfres
else
stop("statcheck did not find any results")
}

else
if (!pdfs & htmls) {
if (!pdfs && htmls) {
if (!is.null(htmlres))
Res <- htmlres
else
stop("statcheck did not find any results")
}

else
if (!pdfs & !htmls)
if (!pdfs && !htmls)
stop("No PDF or HTML found")


Expand Down
4 changes: 2 additions & 2 deletions R/decision_error_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ decision_error_test <- function(reported_p, computed_p,
# check errors for different combinations of <>= -------------------------

# treat p = alpha as significant
if(pEqualAlphaSig == TRUE){
if(pEqualAlphaSig){
if(test_comparison == "="){

if(p_comparison == "="){
Expand Down Expand Up @@ -73,7 +73,7 @@ decision_error_test <- function(reported_p, computed_p,
return(NA)

# treat p = alpha as significant
} else if (pEqualAlphaSig == FALSE){
} else if (!pEqualAlphaSig){

if(test_comparison == "="){

Expand Down
2 changes: 1 addition & 1 deletion R/error_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ error_test <- function(reported_p, test_type, test_stat,

# p values smaller or equal to zero are errors ---------------------------

if(pZeroError == TRUE & reported_p <= 0){
if(pZeroError && reported_p <= 0){
error <- TRUE
return(error)
}
Expand Down
2 changes: 1 addition & 1 deletion R/plot.statcheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ plot.statcheck <- function(
x[[VAR_P_COMPARISON]][ns] <- ">"
x[[VAR_REPORTED_P]][ns] <- alpha

if (APAstyle == TRUE) {
if (APAstyle) {

# Add vector "Type" to statcheck object, specifying whether observations are
# correctly reported, reporting inconsistencies, or decision errors.
Expand Down
2 changes: 1 addition & 1 deletion R/process_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ process_stats <- function(test_type, test_stat, df1, df2, reported_p,
# tailed test, classify the result as consistent
# don't apply this correction if OneTailedTests == FALSE, because this already
# forces statcheck to treat all results as one-tailed tests
if(OneTailedTxt == TRUE & OneTailedTests == FALSE){
if(OneTailedTxt && !OneTailedTests){

# select only results where the phrase "one-tailed", "one-sided" or
# "directional" was mentioned in text, and that were an error when
Expand Down
15 changes: 6 additions & 9 deletions R/statcheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ statcheck <- function(texts,
# progress bar. This is mainly useful for the unit tests; otherwise hundreds
# of progress bars would be printed during testing and that makes the test
# results hard to read
if(messages == TRUE){
if(messages){
message("Extracting statistics...")
pb <- utils::txtProgressBar(max = length(text), style = 3)
}
Expand Down Expand Up @@ -195,14 +195,14 @@ statcheck <- function(texts,
rm(nhst)

# update the progress bar
if(messages == TRUE){
if(messages){
utils::setTxtProgressBar(pb, i)
}

}

# close progress bar
if(messages == TRUE){
if(messages){
close(pb)
}

Expand All @@ -215,11 +215,8 @@ statcheck <- function(texts,
# same as the automated 1-tailed test detection (switched on with the
# argument: OneTailedTxt). The latter works more subtly (see comments in
# process_stats()).
if (OneTailedTests == TRUE) {
two_tailed <- FALSE
} else {
two_tailed <- TRUE
}
two_tailed <- !OneTailedTests


# create empty variables to fill out during the loop
Res$Computed <- rep(NA, nrow(Res))
Expand Down Expand Up @@ -279,7 +276,7 @@ statcheck <- function(texts,

# Return ------------------------------------------------------------------

if (AllPValues == FALSE) {
if (!AllPValues) {

# Return message when there are no results
if (nrow(Res) > 0) {
Expand Down