search for: coltraits

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

Did you mean: cfgtraits
2010 Jan 29
1
apply function with grouped columns
...4 <- c(4, 1, 1, 1) myData <- data.frame(v1=v1, v2=v2, v3=v3, v4=v4) myData #The observations 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(r...