【问题标题】:Reformatting procrustes coordinates in R重新格式化在 R 中处理坐标
【发布时间】:2015-08-06 16:56:30
【问题描述】:

我对 164 个机翼形状数据文件进行了 procrustes 分析,每个文件包含 8 个地标;

 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”。 到目前为止,我真的很难做到这一点。

任何帮助都会很棒。 谢谢

【问题讨论】:

  • 不清楚 $coords 是如何嵌套在 Procrustescoords 对象中的,能否粘贴到 str(Procrustescoords) 的输出中
  • 我已经添加了 str(Procrustescoords) 的输出,谢谢
  • matrix(unlist(Procrustescoords), ncol = (2*length(Procrustescoords))) 怎么样,然后用paste0(c("X", "Y"), rep(seq_along(Procrustescoords), each=2)) 分配列名

标签: r geometry format morphological-analysis


【解决方案1】:

我设法解决了这个问题

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]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-02
    • 2021-11-09
    • 2016-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多