I am new to R coding and I am trying to split column A into two different groups based on the results of categorical values given in the column "Outcome". Then I want to perform a t-test on them.
The data looks like this:
Column "A" = 4, 6, 8, 10, 11...
Column "Outcome" = Disease, Disease, No disease...
I want to split column "A" which is a column containing continuous values into two different groups/columns based on if they have the disease or not.
for eg: I want the data to look as follows:
Disease vector: 4, 6..... Non disease vector: 10, 11,.....
I tried the following command and it separated column A into two groups based on the values in column "outcome". But I want to assign the values to vectors 1 and 2 so that I can use the t.test command i.e., t.test(vector1,vector2)
.
The command I used was:
split(data$A, f = data$Outcome)
I also tried using an if-else command, but that didn't work either.
I know this should be something very easy, but I can't find the proper command to do this.