[R] Help with error: arguments imply differing number of rows

Boris Steipe boris.steipe at utoronto.ca
Sat Mar 14 16:44:10 CET 2015


Not the same. Read carefully...
                                                   
> $ edge       : int [1:15, 1:2] 10 11 12 13 14 14 13 12 15 15 ...
> $ edge       : int [1:15, 1:2] 10 11 12 13 14 15 15 14 16 16 ...
                                                ^^... etc

B.


On Mar 14, 2015, at 11:34 AM, Aman Gill <amango at gmail.com> wrote:

> 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]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list