welch.test returns NaN I would like to test the difference between treatments. Anova worked fine, but i have unequal variances (the normality according to shapiro test was OK). Actually one can see that treatment S has a zero variance. I tried Welch.test but it does not work. Please explain me why Welch Test does not work and how can i test the difference between treatments with post-hoc analysis for my data.
Treatment     WG
1          H     NA
2          H  60.00
3          H  57.14
4          H  42.86
5         HS     NA
6         HS  85.71
7         HS  88.89
8         HS 100.00
9          S 100.00
10         S 100.00
11         S 100.00
12         S 100.00

str(d)
'data.frame':   12 obs. of  2 variables:
 $ Treatment: Factor w/ 3 levels "H","HS","S": 1 1 1 1 2 2 2 2 3 3 ...
 $ WG       : num  NA 60 57.1 42.9 NA ...


d.aov<-aov(WG~Treatment, data=d)
summary(d.aov)
            Df Sum Sq Mean Sq F value   Pr(>F)    
Treatment    2   4013  2006.3   49.94 7.19e-05 ***
Residuals    7    281    40.2                     
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
2 observations deleted due to missingness
shapiro.test(residuals(object=d.aov))

Shapiro-Wilk normality test

data:  residuals(object = d.aov)
W = 0.9515, p-value = 0.6862

 bartlett.test(WG ~ Treatment, data=d)

Bartlett test of homogeneity of variances

 data:  WG by Treatment
 Bartlett's K-squared = Inf, df = 2, p-value < 2.2e-16
  library(onewaytests)
  welch.test(WG~Treatment, d, rate = 0, na.rm=TRUE, verbose=TRUE)
  Welch's Heteroscedastic F Test (alpha = 0.05) 

  data : WG and Treatment 

  statistic  : NaN 
  num df     : 2 
  denom df   : NaN 
  p.value    : NaN 

 Error in if (p.value > alpha) { : missing value where TRUE/FALSE    needed

oneway.test(WG~Treatment, d,na.action=na.omit, var.equal=FALSE)

    One-way analysis of means (not assuming equal variances)

    data:  WG and Treatment
    F = NaN, num df = 2, denom df = NaN, p-value = NA

 A: First, there are some puzzling anomalies in your data.


*

*You have one missing observation out of four for each of the first two groups.

*Also, of particular interest is that some observations are to the
nearest integer and some are to the nearest tenth.
As you say, there is 0 variance in the last group, possibly
because of rounding. 

*Without understanding the reasons for these
peculiarities, I would be reluctant to base important
conclusions on the data you present--even if all tests ran perfectly in software.
You are correct that the 'Welch ANOVA' implemented in the R 
procedure oneway.test gives NAs. I believe this is because
the formula for denominator df does not permit 0 variances.
Comparing H vs. HS, H vs. S, and HS vs. S, with three 2-sample
Welch  t tests, I get P-values 0.006, 0.012, and 0.190, respectively.
t.test(h, hs)$p.val; t.test(h, s)$p.val;  t.test(hs,s)$p.val
[1] 0.00567182
[1] 0.01266049
[1] 0.1898282

So, taking the data to be valid, it seems that the last two groups
do not differ significantly, while the first differs significantly
from the other two. P-values are small enough that it seems OK to
take the two significant differences at face value.
Finally, I did an experiment artificially 'unrounding' the ties
in the third group so that oneway.test will run.
h = c(60, 57.14, 42.86)
hs = c(85.71, 88.89, 100)
s1 = c(99.8, 99.9, 100.1, 100.2)  # 'unrounded'
x = c(h, hs, s1)
g = as.factor(c(1,1,1,2,2,2,3,3,3,3))
oneway.test(x ~ g)

        One-way analysis of means (not assuming equal variances)

data:  x and g
F = 32.514, num df = 2.0000, denom df = 2.6686, p-value = 0.01337

This experiment seems (a) to clarify that the zero variance was your
problem running oneway.test on your original data, and (b) to
confirm that there are differences among the three groups, that would
justify the ad hoc t tests shown earlier.
A: If one of the treatments has the same value for all replicates (e.g., R1= 9.0, R2= 9.0, R3= 9.0, R4= 9.0), the oneway.test shows p-value = NA. Like, treatment S in your example has the value of 100.0 for all replicates.
A: Honestly, since your data is bounded on the ends (i.e. at 0 and 100) and a considerable proportion of your data is right at one of the bounds (i.e. at 100), I don't think a test assuming normality is the best approach.  Honestly, I would probably use a nonparametric approach.  Like Kruskal-Wallis with Dunn 1964, or maybe a permutation test would be appropriate. I'm not sure how these will play out with these particular data.  Of course, practically speaking, the difference in results will be more impressive to your audience than a p value; be sure to present your results in a practical way, and not to rely too much on p values.
A: I actually got the same error when using welch.test: 
Error in if (p.value > alpha) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In pf(Ftest, df1, df2, lower.tail = F) : NaNs produced 
I had no NaNs in any of the data that I was using while running my tests. However, there were NaNs in other columns of my data. I was able to fix the error by filtering my dataframe for only the data I needed for that specific analysis. This removed the columns that contained NaNs and fixed the issue. All I did was use select in dplyr to do that. =)
