I have this dataset:
values<-c(0.002,0.3,0.4,0.005,0.6,0.2,0.001,0.002,0.3,0.01)
codes<-c("A_1","A_2","A_3","B_1","B_2","B_3","B_4","C_1","C_2","C_3")
names(values)<-codes
In codes, the letter indicates the group and case number in each group. Therefore, I have three groups and from 3 to 4 cases in each group (the actual data set is much larger, but this is a subset).
Then I compute the distance matrix:
dist(values)->dist.m
Now I would like to convert dist.m into a dataset with two columns: one containing the distances "inside" of all groups (the distance between A_1 and A_2, between B_2 and B_4, etc.), and the other containing the distances between "groups" (between A_1 and B_1, between C_1 and B_4, etc.)
Is there an easy way to do this in R?
Any help would be greatly appreciated.
Thank you very much in advance.
Tina.