If this error had happened to me, then immediately after receiving that error I would type traceback() at the R prompt. Hopefully, that will provide some information about what happened.
Based on: Error in data.frame(PD = PDs, SR = SR) : arguments imply differing number of rows: 34, 35 It appears that PDs and SR, whatever they are (referring to the versions on the right hand side of the equals sign), have or imply different numbers of rows. For example, PDs could be a vector of length 34 and SR a vector of length 35. Your task is to figure out how they got constructed inside the pd() function, which will lead to why they are different. This will require some understanding of what happens inside the pd() function, and there, unfortunately, I can't help you. Typing pd at the R prompt might reveal the entire definition of the pd() function, from which you might be able to trace the calculations. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 3/12/15, 10:07 AM, "Aman Gill" <ama...@gmail.com> wrote: >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]] > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.