Skip to content

Commit

Permalink
tolerate abnormality error message and return FALSE
Browse files Browse the repository at this point in the history
incase identical vector input, tolerate error and return not normal
  • Loading branch information
Illustratien committed Mar 11, 2024
1 parent e3994da commit 0d58034
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions R/table_stability.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,21 @@ table_stability <- function(data, trait, genotype, environment, lambda, normaliz
stop("Environment number must above 3")
} else if (sample_number <= 5000 & sample_number >= 3) {
normtest <- function(x){
return(shapiro.test(x)$p.value > 0.05)
res.ntest <- tryCatch({shapiro.test(x)},
error=function(cond){
return(list(p.value=0.01))
})
return(res.ntest$p.value > 0.05)
}
norm.test.name <- "Shapiro"
} else if (sample_number > 5000) {

normtest <- function(x){
return(ad.test(x)$p.value > 0.05)
res.ntest <- tryCatch({ad.test(x)},
error=function(cond){
return(list(p.value=0.01))
})
return(res.ntest$p.value > 0.05)
}
norm.test.name <- "Anderson-Darling"
}
Expand Down Expand Up @@ -209,7 +218,7 @@ table_stability <- function(data, trait, genotype, environment, lambda, normaliz
"Variance.of.rank",
"Deviation.mean.squares",
"Genotypic.superiority.measure"
)
)
if (unit.correct==TRUE){
res <- mutate_at(res,need.squared.si, sqrt)
}
Expand Down
2 changes: 1 addition & 1 deletion man/toolStability-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d58034

Please sign in to comment.