0
NonWarmedLake   WarmedLake
<dbl>   <dbl>
11.0360 16.1640
9.7806  15.0550
12.0790 17.8590
8.3534  9.2103
10.1050 16.0010
8.7436  5.9871
13.7760 11.3040
11.1120 18.5080
15.4840 12.0450
14.0350 12.7530

I am trying to conduct a var.test and an independent samples t-test in R using the above dataset. However, the code does not run properly and it keeps saying grouping factor must have exactly two levels.

tpetzoldt
  • 5,338
  • 2
  • 12
  • 29
  • Can you include your code in your question? See here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – jrcalabrese Apr 06 '23 at 15:47
  • Seems to work fine when using `t.test(df$NonWarmedLake, df$WarmedLake)` – jpsmith Apr 06 '23 at 15:50
  • The code I used for the var test was: var.test(NonWarmedLake ~ WarmedLake, data = fishlengths) – Matt Clark Apr 06 '23 at 15:59
  • using library(tidyverse) – Matt Clark Apr 06 '23 at 16:02
  • 1
    `t.test(y ~ x)` is used when y is numeric and x is a binary factor. `t.test(x, y)` is used when both are numeric, as in your case. Should be the same for `var.test()`, which runs with no problems for me – jpsmith Apr 06 '23 at 16:06
  • thank you, I managed to get it to work using your code, the numeric and binary factors were confusing me! – Matt Clark Apr 06 '23 at 16:12

0 Answers0