Aman Gill
2015-Mar-12 17:07 UTC
[R] Help with error: arguments imply differing number of rows
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_treePhylogenetic 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_treePhylogenetic 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]]
PIKAL Petr
2015-Mar-13 11:31 UTC
[R] Help with error: arguments imply differing number of rows
Hi Without further information you probably do not get answers. Everything seems to be same so the only reason can be that the objects seems to be same but they have some inner distinctions, maybe type of variables. Are results of str(your.objects) same in equivalent objects? Cheers Petr> -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Aman > Gill > Sent: Thursday, March 12, 2015 6:08 PM > To: r-help at r-project.org > Subject: [R] Help with error: arguments imply differing number of rows > > 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 at 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.________________________________ Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny pouze jeho adres?t?m. Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho syst?mu. Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat. Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i zpo?d?n?m p?enosu e-mailu. V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?: - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu. - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce s dodatkem ?i odchylkou. - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech. - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi ?i osob? j?m zastoupen? zn?m?. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.
Aman Gill
2015-Mar-14 15:34 UTC
[R] Help with error: arguments imply differing number of rows
Thanks for the reply. The results of str() are indeed the same. Is there anything else I can check that might explain the difference?> str(phyl_tree)List of 4 $ edge : int [1:15, 1:2] 10 11 12 13 14 14 13 12 15 15 ... $ Nnode : int 7 $ tip.label : chr [1:9] "Heliantheae" "Eupatorieae" "Helenieae" "Gnaphalieae" ... $ edge.length: num [1:15] 1 1 1 1 1 1 2 1 2 1 ... - attr(*, "class")= chr "phylo" - attr(*, "order")= chr "cladewise"> > str(chem_tree)List of 4 $ edge : int [1:15, 1:2] 10 11 12 13 14 15 15 14 16 16 ... $ Nnode : int 7 $ tip.label : chr [1:9] "Heliantheae" "Helenieae" "Eupatorieae" "Astereae" ... $ edge.length: num [1:15] 1 2 1 1 1 1 1 1 1 1 ... - attr(*, "class")= chr "phylo" - attr(*, "order")= chr "cladewise"> str(phyl_data)int [1:35, 1:9] 0 0 0 1 0 0 0 0 0 1 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:35] "Uroleucon_aeneum" "Uroleucon_aff_atripes" "Uroleucon_amamianum" "Uroleucon_ambrosiae" ... ..$ : chr [1:9] "Heliantheae" "Eupatorieae" "Helenieae" "Gnaphalieae" ...> > str(chem_data)int [1:35, 1:9] 0 0 0 1 0 0 0 0 0 1 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:35] "Uroleucon_aeneum" "Uroleucon_aff_atripes" "Uroleucon_amamianum" "Uroleucon_ambrosiae" ... ..$ : chr [1:9] "Heliantheae" "Helenieae" "Eupatorieae" "Astereae" ... On Fri, Mar 13, 2015 at 7:31 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote:> Hi > > Without further information you probably do not get answers. Everything > seems to be same so the only reason can be that the objects seems to be > same but they have some inner distinctions, maybe type of variables. > > Are results of > > str(your.objects) > > same in equivalent objects? > > Cheers > Petr > > > -----Original Message----- > > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Aman > > Gill > > Sent: Thursday, March 12, 2015 6:08 PM > > To: r-help at r-project.org > > Subject: [R] Help with error: arguments imply differing number of rows > > > > 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 at 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. > > ________________________________ > Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou > ur?eny pouze jeho adres?t?m. > Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? > neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie > vyma?te ze sv?ho syst?mu. > Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email > jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat. > Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi > ?i zpo?d?n?m p?enosu e-mailu. > > V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?: > - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? > smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu. > - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; > Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany > p??jemce s dodatkem ?i odchylkou. > - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve > v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech. > - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za > spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n > nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto > emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich > existence je adres?tovi ?i osob? j?m zastoupen? zn?m?. > > This e-mail and any documents attached to it may be confidential and are > intended only for its intended recipients. > If you received this e-mail by mistake, please immediately inform its > sender. Delete the contents of this e-mail with all attachments and its > copies from your system. > If you are not the intended recipient of this e-mail, you are not > authorized to use, disseminate, copy or disclose this e-mail in any manner. > The sender of this e-mail shall not be liable for any possible damage > caused by modifications of the e-mail or by delay with transfer of the > email. > > In case that this e-mail forms part of business dealings: > - the sender reserves the right to end negotiations about entering into a > contract in any time, for any reason, and without stating any reasoning. > - if the e-mail contains an offer, the recipient is entitled to > immediately accept such offer; The sender of this e-mail (offer) excludes > any acceptance of the offer on the part of the recipient containing any > amendment or variation. > - the sender insists on that the respective contract is concluded only > upon an express mutual agreement on all its aspects. > - the sender of this e-mail informs that he/she is not authorized to enter > into any contracts on behalf of the company except for cases in which > he/she is expressly authorized to do so in writing, and such authorization > or power of attorney is submitted to the recipient or the person > represented by the recipient, or the existence of such authorization is > known to the recipient of the person represented by the recipient. >[[alternative HTML version deleted]]
MacQueen, Don
2015-Mar-18 22:00 UTC
[R] Help with error: arguments imply differing number of rows
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" <amango at 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 at 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.