I have as a function answer the RMSEA, GFI, NFI and CFI vectors that can contain all the same values. In the sequence I use the algorithm below to test the normality through the shapiro-wilk test. When the values are all equal it returns error of the form
Error in shapiro.test (RMSEA): all 'x' values are identical
and the rest of the algorithm fails because of this problem. How can I check if the values of the vectors are all equal and do not run the test in this case.
# TESTE DE NORMALIDADE
t1 <- shapiro.test(RMSEA)
t2 <- shapiro.test(GFI)
t3 <- shapiro.test(NFI)
t4 <- shapiro.test(CFI)
estt <- as.numeric(c(t1$statistic, t2$statistic, t3$statistic,t4$statistic))
valorp <- c(t1$p.value, t2$p.value, t3$p.value, t4$p.value)
resultados <- cbind(estt, valorp)
rownames(resultados) <- c("SHAPIRO-WILK RMSEA","SHAPIRO-WILK GFI","SHAPIRO-WILK NFI","SHAPIRO-WILK CFI")
colnames(resultados) <- c("Estatística", "p")
print(resultados)