Hello, I am trying to run a Welch two-sided t-test on the following sample data frame:
structure(list(CellType = structure(c(1L, 2L, 3L, 3L, 1L, 1L, 2L, 3L, 3L, 1L), .Label = c("CellA", "CellB", "CellC"), class = "factor"), Gene1 = structure(c(2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L), .Label = c("Mut", "Wt"), class = "factor")), class = "data.frame", row.names = c(NA,-10L))
I think the code might look something like this so I can run this t-test between specific Cell Types and Gene1 (having only binary values of Mutant vs Wild type):
t.test(Test$Gene1[Test$CellTypeT=="CellA"],
Test$Gene1[Test$CellType=="CellB"])$p.value
However, this code doesn't work as is and might require conversion of text values (i.e. "Mut" and "Wt") into numeric values that can be recognized by t-test function. Any suggestions on how I can remedy this situation?