Error in table(): all arguments must have the same length

Hi! I am trying to produce a table for a haplotype network with the library pegas. However, in the very step of producing the table a keep getting this error and I am not very sure where is the mistake:
Error in table(hap = ind, pop = attr(dna, "dimnames")[[1]][values]) :
all arguments must have the same length

library(ape)
library(pegas)

data<-read.FASTA("C:\path\to\fasta\file.fasta")
checkAlignment(data)
datahaplo<-haplotype(data)
datahaplo
datahaplo<-sort(datahaplo, what = "labels")
dataNet<-haploNet(datahaplo)
countHap <- function(hap = h, dna = x){with(stack(setNames(attr(hap, "index"), rownames(hap))), table(hap=ind, pop=attr(dna, "dimnames")[[1]][values]))}
write.table(countHap(datahaplo, data), file=file.txt, sep="\t", quote=FALSE)

Thank you very much for your help!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.