Skip to content
Prev 314702 / 398502 Next

Need help on dataframe

This is a slight modification of John's approach using 6 variables and 28
observations:

set.seed(42)
xx  <-  data.frame(aa = 1:28, matrix(sample(1:6, 6*28,  
    replace = TRUE), nrow= 28))
dd  <- ((1:nrow(xx)-1) %/% 7) +1
result <- aggregate(xx[,-1], by=list(dd), FUN=mean)[dd,-1]
result <- data.frame(aa=xx$aa, result)
row.names(result) <- row.names(xx)

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352