# This example shows how to convert a data set to the appropriate format for analysis # For example if variables are separated by group # Assume three groups: A, B and C # A Variable Diameter and a variable Mass # The Diameter of group A is in the first column, the Diameter of group B in the second and that of group C in the third # The Mass of group A is in the fourth column, the Mass of group B in the fifth and that of group C in the sixth. # The Data are in a data frame called MyData MyData<-structure(list(DiameterA = c(1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9), DiameterB = c(2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9), DiameterC = c(3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9), MassA = c(4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9), MassB = c(5, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9), MassC = c(6, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9 )), .Names = c("DiameterA", "DiameterB", "DiameterC", "MassA", "MassB", "MassC"), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"), class = "data.frame") # first define the groups so that this can become the grouping variable: A<-rep('A',10) B<-rep('B',10) C<-rep('C',10) Group<-c(A,B,C) Group<-as.data.frame(Group) Group Diameter<-c(MyData[,1],MyData[,2],MyData[,3]) Diameter<-as.data.frame(Diameter) Diameter Mass<-c(MyData[,4],MyData[,5],MyData[,6]) Mass<-as.data.frame(Mass) Mass # Define a new data frame with all the information appropriately declared as variables. NewData<-cbind(Group,Diameter,Mass) NewData