Think matrix!
This version is the same as I sent yesterday plus I constructed
result3 to give two columns, the first is the vector of 900 numbers
you requested and the second is the group labels
## construct data
result <- matrix(rnorm(30*30, mean=50,
sd=seq(1, 10, length=30)),
30, 30, byrow=TRUE)
print(result, digits=1) ## verify standard deviations
apply(result, 2, var)^.5
## sort each of the 30 groups
result2 <- apply(result, 2, sort)
apply(result2, 2, var)^.5 ## verify standard deviations
print(result2, digits=1)
## rearrange into a single vector with a column of group labels
result3 <- cbind(y=as.vector(result2), group=as.vector(col(result2)))
result3
As an aside, you can start a sequence with a zero-length vector.
x <- numeric(0)
x
x <- append(x, 1:5)
x
x <- append(x, 1:5)
x
|