Say I have:
#Continuous variable 1
x1<-rnorm(15, 1, .5)
#Continuous Variable 2
x2<-rnorm(15,1,.5)
#Sample Names
s.names<-c("S3","S5","S8","S14","S11","S13","S15","S12","S10","S2","S1","S6","S7","S4","S9")
df.temp<-data.frame(s.names,x1,x2)
df.temp
s.names x1 x2
1 S3 0.7025583 1.6616103
2 S5 0.4401055 1.5715047
3 S8 1.3691886 0.7754010
4 S14 1.1365712 1.2697196
5 S11 2.1193612 0.5968068
6 S13 0.6834145 1.4669863
7 S15 0.7050808 1.3287179
8 S12 2.0293910 0.7502497
9 S10 0.6807918 1.0793561
10 S2 0.6809873 0.7454851
11 S1 0.3775086 0.3150030
12 S6 2.1235465 1.4864190
13 S7 1.1657259 1.3279573
14 S4 1.4629794 0.6146412
15 S9 0.6916639 0.4507309
Now let us try and order.
df.temp[order(df.temp$s.names),]
s.names x1 x2
11 S1 0.3775086 0.3150030
9 S10 0.6807918 1.0793561
5 S11 2.1193612 0.5968068
8 S12 2.0293910 0.7502497
6 S13 0.6834145 1.4669863
4 S14 1.1365712 1.2697196
7 S15 0.7050808 1.3287179
10 S2 0.6809873 0.7454851
1 S3 0.7025583 1.6616103
14 S4 1.4629794 0.6146412
2 S5 0.4401055 1.5715047
12 S6 2.1235465 1.4864190
13 S7 1.1657259 1.3279573
3 S8 1.3691886 0.7754010
15 S9 0.6916639 0.4507309
But my issue is I have trouble now manipulating the data frame. In particular, when I try and order or sort the s.names it always returns something along the lines of >S1,S10,S11,S12...,S2,S20,S21,S3,S4,S5,S6,S7 etc. (not 21 samples but see above example.) The reason is, of course, I am trying to re-arrange the data frame by rows. order() and sort() have had issues with this.
Additionally, I am wondering, if I want to "bootstrap" or randomly change the rows around for statistical reasonssamples linked to each other as in S1 will have a corresponding x1 and x2 value, it will just be in a different, perhaps random order e.g. S5,S11,S6, etc.
My end goal is to do regression such as ANOVA(), cov() and cor()
EDIT: Added more code