Search code examples
rstatisticskruskal-wallisdunn.test

Dunn test in R: error message about something being coerced to a factor


I am trying to conduct a Dunn test in R. This is my code: DTP = dunnTest(P~SoilSeries, data=df3, method="bh") I get this error message: Warning message: SoilSeries was coerced to a factor. I don't know what to do. I turned SoilSeries into a factor with as.factor but then df3 was no longer a table. I'm a beginner and am very confused, so would really appreciate any help. Thank you!


Solution

  • I assume SoilSeries is a column in df3. And I assume df3 is a dataframe, if not you can first convert df3 to df,

    df3 <- as.data.frame(df3)
    

    Then use the as.factor

    df3$SoilSeries <- as.factor(df3$SoilSeries)
    

    And Warning message: SoilSeries was coerced to a factor. is not an error, R simply converted SoilSeries to factor for the Dunn Test.