我使用以下方法对 164 个机翼形状数据文件(每个文件有 8 个地标)进行了 Procrustes 分析;
Procrustescoords <- list()
for (a in 1:length(flightfiles)){
Procrustescoords <-c(Procrustescoords,gpagen(array(data=Flights[,,a],dim=c(8,2,1)), Proj= TRUE, ShowPlot = TRUE, ProcD = TRUE, PrinAxes = TRUE, curves = NULL, surfaces = NULL)[1])
它为每个个体产生输出;
$coords
, , 1
[,1] [,2]
[1,] -0.46629916 0.01094528
[2,] -0.17442692 0.07026679
[3,] 0.17749109 0.10209531
[4,] 0.35896138 0.02312385
[5,] 0.36198915 0.01257036
[6,] 0.28832972 -0.05956911
[7,] 0.03323332 -0.14496370
[8,] -0.57927857 -0.01446878
str(Procrustescoords) 的输出为;
> str(Procrustescoords)
List of 164
$ coords: num [1:8, 1:2, 1] 0.493 0.315 -0.269 -0.269 -0.269 ...
$ coords: num [1:8, 1:2, 1] 0.472 0.197 -0.1 -0.364 -0.371 ...
$ coords: num [1:8, 1:2, 1] -0.485 -0.134 0.115 0.355 0.359 ...
$ coords: num [1:8, 1:2, 1] 0.39136 0.30866 0.05409 -0.0059 -0.00196 ...
$ coords: num [1:8, 1:2, 1] 0.479 0.309 -0.188 -0.327 -0.33 ...
$ coords: num [1:8, 1:2, 1] 0.107 0.149 0.267 0.29 0.288 ...
$ coords: num [1:8, 1:2, 1] 0.496 0.202 -0.236 -0.309 -0.327 ...
$ coords: num [1:8, 1:2, 1] 0.488 0.2 -0.249 -0.317 -0.33 ...
...所有 164 个人依此类推
我现在希望将输出坐标重新格式化为一个表,其中每一行都是一个单独的(文件),并且坐标显示为“X1”、“Y1”、“X2”、“Y2”等列,... “X8”、“Y8”。 到目前为止,我真的很难做到这一点。
任何帮助都会很棒。 谢谢
我设法使用
解决了这个问题ProcTable <- matrix(nrow=length(Specimens),ncol=16)
rownames(ProcTable)<-Specimens
for (x in 1:length(Specimens)){
flight<-read.table(flightfiles[x],skip=1,col.names=c("x","y"), nrow = length(readLines(flightfiles[x])) - 2)
ProcTable[x,1]<-flight[1,1]
ProcTable[x,3]<-flight[2,1]
ProcTable[x,5]<-flight[3,1]
ProcTable[x,7]<-flight[4,1]
ProcTable[x,9]<-flight[5,1]
ProcTable[x,11]<-flight[6,1]
ProcTable[x,13]<-flight[7,1]
ProcTable[x,15]<-flight[8,1]
ProcTable[x,2]<-flight[1,2]
ProcTable[x,4]<-flight[2,2]
ProcTable[x,6]<-flight[3,2]
ProcTable[x,8]<-flight[4,2]
ProcTable[x,10]<-flight[5,2]
ProcTable[x,12]<-flight[6,2]
ProcTable[x,14]<-flight[7,2]
ProcTable[x,16]<-flight[8,2]
}