R语言 如何解决ggiNEXT图中的错误:“参数表示行数不同”

nc1teljy  于 2022-12-30  发布在  其他
关注(0)|答案(1)|浏览(240)

我尝试使用Chao等人2014年的iNEXT绘制多样性指数,并遵循here编写的指南
我有这个频率数据集:

Freq_sp <-  structure(list(sp = c("sp 1", "sp 2", "sp 3", "sp 4", "sp 5", 
    "sp 6", "sp 7", "sp 8", "sp 9", "sp 10", "sp 11", "sp 12", "sp 13", 
    "sp 14", "sp 15", "sp 16", "sp 17", "sp 18", "sp 19", "sp 20", 
    "sp 21", "sp 22", "sp 23", "sp 24", "sp 25", "sp 26", "sp 27", 
    "sp 28", "sp 29", "sp 30", "sp 31", "sp 32", "sp 33", "sp 34"
    ), N = c("677", "52", "15", "45", "109", "8", "12", "1", "14", 
    "17", "1", "32", "18", "6", "1", "27", "8", "98", "1", "1", "3", 
    "102", "3", "32", "15", "11", "3", "2", "3", "2", "9", "23", 
    "2", "1")), .Names = c("sp", "N"), class = "data.frame", row.names = c("1", 
    "110", "2", "3", "4", "5", "6", "8", "9", "10", "11", "12", "13", 
    "14", "15", "16", "17", "18", "19", "20", "21", "22", "24", "25", 
    "27", "28", "29", "30", "32", "33", "34", "35", "36", "37"))

其中第一个(sp1 = 677)是观测值的总和(按照说明)。
我按要求列成清单:

freq_list <- list(as.numeric(Freq_sp$N))

我进行了计算,输出是有意义且正确的

out <- iNEXT(freq_list, q = 0, datatype = "incidence_freq")

但我没法画出来:

ggiNEXT(out, type=3)

我收到此错误消息:

Error in data.frame(do.call("rbind", z), site = rep(names(z), sapply(z,  : 
  arguments imply differing number of rows: 40, 0

有什么建议,这是错的吗?
我可以很容易地产生教程图。我正在运行R 3.3.3.I设法解决这个问题,首先在Excel表中组织数据。此外,我怀疑这个问题与我在第一次尝试中只有一个社区/站点有关。我可以看到,在Chao等人的其他一些函数中,她指定数据类型为“incidence_freq_count“并且明确地写着这适用于单个社区。但是,这个数据类型对于我正在运行的函数无效(iNEXT)。幸运的是,我 * 确实 * 有几个社区,因此问题自行解决。当我创建一个输入文件时(从Excel)并将.csv文件导入为data frame,其结构如下(三个社区),运行良好:

freq <- structure(list(taxa = structure(c(387L, 142L, 253L, 310L, 321L, 
332L, 343L, 354L, 365L, 376L, 143L, 154L, 165L, 176L, 187L, 198L, 
209L, 220L, 231L, 242L, 254L, 265L, 276L, 287L, 298L, 305L, 306L, 
307L, 308L, 309L, 311L, 312L, 313L, 314L, 315L, 316L, 317L, 318L, 
319L, 320L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 
331L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 341L, 342L, 
344L, 345L, 346L, 347L, 348L, 349L, 350L, 351L, 352L, 353L, 355L, 
356L, 357L, 358L, 359L, 360L, 361L, 362L, 363L, 364L, 366L, 367L, 
368L, 369L, 370L, 371L, 372L, 373L, 374L, 375L, 377L, 378L, 379L, 
380L, 381L, 382L, 383L, 384L, 385L, 386L, 144L, 145L, 146L, 147L, 
148L, 149L, 150L, 151L, 152L, 153L, 155L, 156L, 157L, 158L, 159L, 
160L, 161L, 162L, 163L, 164L, 166L, 167L, 168L, 169L, 170L, 171L, 
172L, 173L, 174L, 175L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 
184L, 185L, 186L, 188L, 189L, 190L, 191L, 192L, 193L, 194L, 195L, 
196L, 197L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 
208L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 219L, 
221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 229L, 230L, 232L, 
233L, 234L, 235L, 236L, 237L, 238L, 239L, 240L, 241L, 243L, 244L, 
245L, 246L, 247L, 248L, 249L, 250L, 251L, 252L, 255L, 256L, 257L, 
258L, 259L, 260L, 261L, 262L, 263L, 264L, 266L, 267L, 268L, 269L, 
270L, 271L, 272L, 273L, 274L, 275L, 277L, 278L, 279L, 280L, 281L, 
282L, 283L, 284L, 285L, 286L, 288L, 289L, 290L, 291L, 292L, 293L, 
294L, 295L, 296L, 297L, 299L, 300L, 301L, 302L, 303L, 304L, 1L, 
21L, 32L, 43L, 54L, 65L, 76L, 87L, 98L, 2L, 12L, 13L, 14L, 15L, 
16L, 17L, 18L, 19L, 20L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 
30L, 31L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 44L, 
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 55L, 56L, 57L, 58L, 
59L, 60L, 61L, 62L, 63L, 64L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 
73L, 74L, 75L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 
88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 99L, 100L, 
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 109L, 120L, 131L, 136L, 137L, 138L, 139L, 
140L, 141L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 
119L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L, 130L, 
132L, 133L, 134L, 135L), .Label = c("Fruit1", "Fruit10", "Fruit100", 
"Fruit101", "Fruit102", "Fruit103", "Fruit104", "Fruit105", "Fruit106", 
"Fruit107", "Fruit108", "Fruit11", "Fruit12", "Fruit13", "Fruit14", 
"Fruit15", "Fruit16", "Fruit17", "Fruit18", "Fruit19", "Fruit2", 
"Fruit20", "Fruit21", "Fruit22", "Fruit23", "Fruit24", "Fruit25", 
"Fruit26", "Fruit27", "Fruit28", "Fruit29", "Fruit3", "Fruit30", 
"Fruit31", "Fruit32", "Fruit33", "Fruit34", "Fruit35", "Fruit36", 
"Fruit37", "Fruit38", "Fruit39", "Fruit4", "Fruit40", "Fruit41", 
"Fruit42", "Fruit43", "Fruit44", "Fruit45", "Fruit46", "Fruit47", 
"Fruit48", "Fruit49", "Fruit5", "Fruit50", "Fruit51", "Fruit52", 
"Fruit53", "Fruit54", "Fruit55", "Fruit56", "Fruit57", "Fruit58", 
"Fruit59", "Fruit6", "Fruit60", "Fruit61", "Fruit62", "Fruit63", 
"Fruit64", "Fruit65", "Fruit66", "Fruit67", "Fruit68", "Fruit69", 
"Fruit7", "Fruit70", "Fruit71", "Fruit72", "Fruit73", "Fruit74", 
"Fruit75", "Fruit76", "Fruit77", "Fruit78", "Fruit79", "Fruit8", 
"Fruit80", "Fruit81", "Fruit82", "Fruit83", "Fruit84", "Fruit85", 
"Fruit86", "Fruit87", "Fruit88", "Fruit89", "Fruit9", "Fruit90", 
"Fruit91", "Fruit92", "Fruit93", "Fruit94", "Fruit95", "Fruit96", 
"Fruit97", "Fruit98", "Fruit99", "morph1", "morph10", "morph11", 
"morph12", "morph13", "morph14", "morph15", "morph16", "morph17", 
"morph18", "morph19", "morph2", "morph20", "morph21", "morph22", 
"morph23", "morph24", "morph25", "morph26", "morph27", "morph28", 
"morph29", "morph3", "morph30", "morph31", "morph32", "morph33", 
"morph4", "morph5", "morph6", "morph7", "morph8", "morph9", "soil1", 
"soil10", "soil100", "soil101", "soil102", "soil103", "soil104", 
"soil105", "soil106", "soil107", "soil108", "soil109", "soil11", 
"soil110", "soil111", "soil112", "soil113", "soil114", "soil115", 
"soil116", "soil117", "soil118", "soil119", "soil12", "soil120", 
"soil121", "soil122", "soil123", "soil124", "soil125", "soil126", 
"soil127", "soil128", "soil129", "soil13", "soil130", "soil131", 
"soil132", "soil133", "soil134", "soil135", "soil136", "soil137", 
"soil138", "soil139", "soil14", "soil140", "soil141", "soil142", 
"soil143", "soil144", "soil145", "soil146", "soil147", "soil148", 
"soil149", "soil15", "soil150", "soil151", "soil152", "soil153", 
"soil154", "soil155", "soil156", "soil157", "soil158", "soil159", 
"soil16", "soil160", "soil161", "soil162", "soil163", "soil164", 
"soil165", "soil166", "soil167", "soil168", "soil169", "soil17", 
"soil170", "soil171", "soil172", "soil173", "soil174", "soil175", 
"soil176", "soil177", "soil178", "soil179", "soil18", "soil180", 
"soil181", "soil182", "soil183", "soil184", "soil185", "soil186", 
"soil187", "soil188", "soil189", "soil19", "soil190", "soil191", 
"soil192", "soil193", "soil194", "soil195", "soil196", "soil197", 
"soil198", "soil199", "soil2", "soil20", "soil200", "soil201", 
"soil202", "soil203", "soil204", "soil205", "soil206", "soil207", 
"soil208", "soil209", "soil21", "soil210", "soil211", "soil212", 
"soil213", "soil214", "soil215", "soil216", "soil217", "soil218", 
"soil219", "soil22", "soil220", "soil221", "soil222", "soil223", 
"soil224", "soil225", "soil226", "soil227", "soil228", "soil229", 
"soil23", "soil230", "soil231", "soil232", "soil233", "soil234", 
"soil235", "soil236", "soil237", "soil238", "soil239", "soil24", 
"soil240", "soil241", "soil242", "soil243", "soil244", "soil245", 
"soil25", "soil26", "soil27", "soil28", "soil29", "soil3", "soil30", 
"soil31", "soil32", "soil33", "soil34", "soil35", "soil36", "soil37", 
"soil38", "soil39", "soil4", "soil40", "soil41", "soil42", "soil43", 
"soil44", "soil45", "soil46", "soil47", "soil48", "soil49", "soil5", 
"soil50", "soil51", "soil52", "soil53", "soil54", "soil55", "soil56", 
"soil57", "soil58", "soil59", "soil6", "soil60", "soil61", "soil62", 
"soil63", "soil64", "soil65", "soil66", "soil67", "soil68", "soil69", 
"soil7", "soil70", "soil71", "soil72", "soil73", "soil74", "soil75", 
"soil76", "soil77", "soil78", "soil79", "soil8", "soil80", "soil81", 
"soil82", "soil83", "soil84", "soil85", "soil86", "soil87", "soil88", 
"soil89", "soil9", "soil90", "soil91", "soil92", "soil93", "soil94", 
"soil95", "soil96", "soil97", "soil98", "soil99", "sum"), class = "factor"), 
    `soil OTU` = c(557560L, 17L, 2101L, 76L, 4219L, 43L, 1239L, 
    9L, 171L, 11941L, 1L, 1L, 4L, 5L, 6L, 12L, 65L, 80L, 30581L, 
    2L, 8508L, 4L, 18L, 20L, 33L, 123L, 210L, 751L, 8606L, 2L, 
    49L, 169L, 318L, 364L, 1345L, 27619L, 94L, 9637L, 102L, 514L, 
    22803L, 2L, 130L, 136L, 154L, 174L, 339L, 709L, 18436L, 26915L, 
    1265L, 105L, 1040L, 22L, 28L, 29L, 383L, 6019L, 8536L, 4L, 
    43L, 146L, 229L, 227L, 3360L, 17889L, 1L, 119L, 1L, 9L, 106L, 
    120L, 2464L, 32L, 139L, 190L, 585L, 1221L, 1L, 3L, 2L, 6L, 
    9L, 22L, 18L, 18L, 41L, 55L, 78L, 82L, 138L, 143L, 195L, 
    150L, 229L, 1083L, 2603L, 5084L, 9936L, 2L, 386L, 23L, 29L, 
    264L, 1450L, 2442L, 2562L, 98L, 9L, 7L, 18L, 16L, 50L, 159L, 
    67L, 225L, 126L, 137L, 141L, 363L, 320L, 334L, 351L, 381L, 
    395L, 671L, 8927L, 9466L, 11L, 262L, 315L, 7191L, 4070L, 
    1L, 845L, 144L, 8434L, 2L, 10L, 12L, 47L, 176L, 485L, 624L, 
    1392L, 15767L, 10527L, 59211L, 46L, 125L, 5918L, 6948L, 2L, 
    5L, 286L, 12L, 196L, 3478L, 1466L, 77L, 620L, 1L, 17L, 209L, 
    599L, 11376L, 1L, 2L, 31L, 103L, 8142L, 11L, 15L, 16L, 19L, 
    39L, 56L, 68L, 146L, 111L, 129L, 172L, 218L, 425L, 390L, 
    1854L, 4206L, 3804L, 5514L, 16711L, 35030L, 24L, 1402L, 4L, 
    12L, 13L, 14L, 17L, 19L, 21L, 27L, 35L, 43L, 111L, 113L, 
    124L, 127L, 138L, 166L, 425L, 2533L, 2587L, 5565L, 1L, 95L, 
    196L, 295L, 305L, 339L, 526L, 630L, 19728L, 1L, 4L, 1131L, 
    113L, 21L, 31L, 616L, 19893L, 6L, 6L, 49L, 7L, 71L, 1457L, 
    1246L, 2562L, 27L, 49L, 66L, 1212L, 9L, 51L, 274L, 2419L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L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L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 52L, 15L, 45L, 109L, 8L, 
    12L, 1L, 14L, 17L, 1L, 32L, 18L, 6L, 1L, 27L, 8L, 98L, 1L, 
    1L, 3L, 102L, 3L, 32L, 15L, 11L, 3L, 2L, 3L, 2L, 9L, 23L, 
    2L, 1L)), .Names = c("taxa", "soil OTU", "fruit ribo types", 
"Morpho"), class = "data.frame", row.names = c(NA, -387L))
4bbkushb

4bbkushb1#

我有same issue as you--但问题已经解决了。
错误是因为out $iNextEst没有命名。我只是随机分配了一个名称,它就给出了图。
这是密码

names(out$iNextEst) <- "out"

ggiNEXT(out, type=3) +
  theme(panel.grid.major=element_blank(), #removes grid lines inside graph
        panel.grid.minor=element_blank(), #removes grid lines inside graph
        axis.line=element_line(colour="black"))+ #creates axes border lines
  theme_classic() +
  scale_x_continuous(name="Sampling Coverage") +
  scale_y_continuous(name= "Species Richness")

Graph here

相关问题