あなたの例はすべてめちゃくちゃです。これは適切な例であり、決して使用しないでくださいas.data.frame(cbind(...))
site=rep(c("Q", "R", "S", "T"), each=500)
grid=sample(1:2, size=2000, replace=TRUE)
spp=rep(c("A", "B", "C", "D", "E"), each=400)
fate=sample(1:5, size=20000, replace=TRUE)
sex=rep(c("M","F"), each=2000)
weight=sample(85:140, size=2000, replace=TRUE)
raw.data=data.frame(site=site, grid=grid, spp=spp, fate=fate, sex=sex, weight=weight)
names(group.spp) <- paste(levels(raw.data$spp), "raw", sep=".")
#------------------------
str(group.spp)
List of 5
$ A.raw:'data.frame': 4000 obs. of 6 variables:
..$ site : Factor w/ 4 levels "Q","R","S","T": 1 1 1 1 1 1 1 1 1 1 ...
..$ grid : int [1:4000] 2 1 2 1 2 1 1 1 1 2 ...
..$ spp : Factor w/ 5 levels "A","B","C","D",..: 1 1 1 1 1 1 1 1 1 1 ...
..$ fate : int [1:4000] 3 2 3 5 5 2 3 2 5 2 ...
..$ sex : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
..$ weight: int [1:4000] 136 93 115 100 97 128 120 124 97 120 ...
$ B.raw:'data.frame': 4000 obs. of 6 variables:
..$ site : Factor w/ 4 levels "Q","R","S","T": 1 1 1 1 1 1 1 1 1 1 ...
..$ grid : int [1:4000] 2 2 1 2 2 2 1 2 2 2 ...
..$ spp : Factor w/ 5 levels "A","B","C","D",..: 2 2 2 2 2 2 2 2 2 2 ...
..$ fate : int [1:4000] 5 5 2 4 3 4 2 3 4 5 ...
..$ sex : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
..$ weight: int [1:4000] 137 126 116 97 97 86 134 103 86 140 ...
$ C.raw:'data.frame': 4000 obs. of 6 variables:
..$ site : Factor w/ 4 levels "Q","R","S","T": 2 2 2 2 2 2 2 2 2 2 ...
..$ grid : int [1:4000] 1 2 1 2 2 2 1 2 2 1 ...
..$ spp : Factor w/ 5 levels "A","B","C","D",..: 3 3 3 3 3 3 3 3 3 3 ...
..$ fate : int [1:4000] 2 4 4 2 5 1 2 1 2 5 ...
..$ sex : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
..$ weight: int [1:4000] 132 85 96 87 91 94 94 122 116 87 ...
$ D.raw:'data.frame': 4000 obs. of 6 variables:
..$ site : Factor w/ 4 levels "Q","R","S","T": 3 3 3 3 3 3 3 3 3 3 ...
..$ grid : int [1:4000] 2 2 2 1 1 2 2 1 1 2 ...
..$ spp : Factor w/ 5 levels "A","B","C","D",..: 4 4 4 4 4 4 4 4 4 4 ...
..$ fate : int [1:4000] 2 4 1 4 2 4 1 5 1 4 ...
..$ sex : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
..$ weight: int [1:4000] 130 139 100 107 126 119 134 110 103 135 ...
$ E.raw:'data.frame': 4000 obs. of 6 variables:
..$ site : Factor w/ 4 levels "Q","R","S","T": 4 4 4 4 4 4 4 4 4 4 ...
..$ grid : int [1:4000] 2 2 1 1 1 1 2 2 2 1 ...
..$ spp : Factor w/ 5 levels "A","B","C","D",..: 5 5 5 5 5 5 5 5 5 5 ...
..$ fate : int [1:4000] 5 5 4 5 5 3 1 4 4 3 ...
..$ sex : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
..$ weight: int [1:4000] 88 96 99 101 119 94 97 132 137 115 ...