[R] Help with error: arguments imply differing number of rows
Aman Gill
amango at gmail.com
Thu Mar 12 18:07:57 CET 2015
Hello,
I am stuck trying to run an analysis using the package picante. I am
running two very similar analyses. One works as expected, but when I try
the other, I get the error:
Error in data.frame(PD = PDs, SR = SR) :
arguments imply differing number of rows: 34, 35
This is strange to me since the data matrix is the same for both analyses
(numbers of rows and columns are the same; the only difference is the order
of the columns). Each analyses requires a phylogenetic tree (.tre file),
and each tree is very similar. Any thoughts as to what's causing this
problem? The problem may be specific to the function I'm using [pd()], but
since the error is a data.frame error I thought I'd ask here. Here is the
code I'm using:
This works:
phyl_tree <- read.nexus("phyl.tre")
phyl_data <- as.matrix(read.table("phyl_matrix.txt"), header=TRUE, sep =
"\t")
pd.result <- pd(phyl_data, phyl_tree, include.root = TRUE)
This fails (this matrix.txt file is the same as above, except that columns
are ordered to match the tree; I have also used the above matrix.txt file)
chem_tree <- read.nexus("chem.tre")
chem_data <- as.matrix(read.table("chem_matrix.txt"), header=TRUE, sep =
"\t")
pd_chem.result <- pd(chem_data, chem_tree, include.root = TRUE)
ERROR:
Error in data.frame(PD = PDs, SR = SR) :
arguments imply differing number of rows: 34, 35
To illustrate that the data for each run are very similar (row and column
names are also the same in both data files):
> phyl_tree
Phylogenetic tree with 9 tips and 7 internal nodes.
Tip labels:
Heliantheae, Eupatorieae, Helenieae, Gnaphalieae, Anthemideae, Astereae, ...
Node labels:
root, minCyn, minCic, HelEurHel, HelEur, GnaAnthAst, ...
Rooted; includes branch lengths.
> nrow(phyl_data)
[1] 35
> ncol(phyl_data)
[1] 9
> class(phyl_data)
[1] "matrix"
> chem_tree
Phylogenetic tree with 9 tips and 7 internal nodes.
Tip labels:
Heliantheae, Helenieae, Eupatorieae, Astereae, Gnaphlieae, Senecioneae, ...
Node labels:
root, minC, minAnth, minSen, minGna, HelHel, ...
Rooted; includes branch lengths.
> nrow(chem_data)
[1] 35
> ncol(chem_data)
[1] 9
> class(chem_data)
[1] "matrix"
[[alternative HTML version deleted]]
More information about the R-help
mailing list