search for: meanbyrowtrait

Displaying 1 result from an estimated 1 matches for "meanbyrowtrait".

Did you mean: meanbyrowtraits
2010 Jan 29
1
apply function with grouped columns
...have either property 1 or property 2 rowFactor <- data.frame(RowTraits=factor(c(1, 2, 1, 2))) rowFactor #The variables have a property that is either present or absent colFactor <- data.frame(ColTraits=factor(c(1, 1, 0, 0))) colFactor #Getting the means for the columns by row groups is easy MeanByRowTraits <- aggregate (myData, rowFactor[1], mean) MeanByRowTraits #But now to get the means for the rows by column groups is awkward rotateData <- data.frame(t(MeanByRowTraits[2:5])) colnames(rotateData) <- c(levels(rowFactor[,1])) rotateData #This is the kind of result I want in the end aggreg...