I am trying to split my data set up for analyses in R. I first want to split them by group, A or B, and then split those groups up by age. I have tried using the split() function as follows:
Data <- read.csv("/users/SLA9DI/Documents/Test.csv")
split(Data,Data$Group)
But then when i try split(Data,Data$Age)
it splits it by only age, and the same thing happens when i try split(Data$Group,Data$Age)
. The data will be used to compare groups of people who are the same age. I also might throw in gender later, so if i could do an even further split by gender within those ages, that would be even more helpful. Example:
Group Age Data Data2
A 13 15 10
A 13 14 6
A 18 13 2
A 8 13 8
A 12 2 2
A 14 2 2
A 16 3 2
A 16 4 4
A 16 23 5
A 16 15 4
B 13 5 5
B 13 56 6
B 18 6 1
B 8 76 6
B 12 7 3
B 14 8 2
B 16 9 2
B 16 10 5
B 16 11 6
B 16 12 7
Edit: Split them into groups, and then split the ages within those groups up, so i can compare the 16 Year Old Group B with the 16 Year old groups A. Further, i may want to split it even further into Gender later, to say compare a 16 Year Old Female in group B or group A, with 16 Year Old Male in Group A or B.