在 R 中创建 Nexus 文件

问题描述

我有一个矩阵,我用来创建一个 nexus 文件

mt = matrix(c(rep(1:5,times = 2),NA,2,5,4,1,3,1),nrow=10)
rownames(mt) <- paste(rep("taxon",10),1:10)
colnames(mt) = c("color","type")
mt
         color type
taxon 1      1   NA
taxon 2      2    2
taxon 3      3    5
taxon 4      4    2
taxon 5      5    4
taxon 6      1    1
taxon 7      2    2
taxon 8      3    5
taxon 9      4    3
taxon 10     5    1

创建我正在使用的 ```mt````(格式标准 - 分类矩阵)的 nexus 文件

charstate = write.nexus.data(mt,file = "charstate.nex",format ="stand",datablock = T)

这将导致:

#NEXUS
[Data written by write.nexus.data.R,Sun Mar 07 13:19:14 2021]
BEGIN DATA;
  DIMENSIONS NTAX=10 NCHAR=2;
  FORMAT DATATYPE=STANDARD MISSING=? GAP=- INTERLEAVE=NO symbols="0123456789";
  MATRIX
    taxon 1       1NA
    taxon 2       22
    taxon 3       35
    taxon 4       42
    taxon 5       54
    taxon 6       11
    taxon 7       22
    taxon 8       35
    taxon 9       43
    taxon 10      51
  ;
END;

但是,我还想在我的 NEXUS 文件中包含 CHARSTATELABELS。示例:


#NEXUS
[Data written by write.nexus.data.R,Sun Mar 07 13:19:14 2021]
BEGIN DATA;
  DIMENSIONS NTAX=10 NCHAR=2;
  FORMAT DATATYPE=STANDARD MISSING=? GAP=- INTERLEAVE=NO symbols="0123456789"
    CHARSTATELABELS 
        1 'color (1 blue,2 yellow,3 red,4 black,5 white)'
        2'type(1 big,2 short,3 medium,4 big-short,5 medium-short)'
; 
    MATRIX

此外,您可以看到符号没有显示正确的编码状态。右边应该是 symbols = "012345" 而不是最初描述的 0 到 9。 如何包含 CHARSTATELABELS 和正确的 ** 符号**?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...