I have a confusing error from R CMD check that I don't get when running the example manually by hand. In the \examples section of an Rd file, I create a GRanges object, then I call a function with the GRanges object, whose first 2 lines are require(GenomicRanges) annoDF <- as.data.frame(anno) # anno is the GRanges object. and that second line gives: Error in as.data.frame.default(anno) : cannot coerce class 'structure("GRanges", package = "GenomicRanges")' into a data.frame Calls: annoGR2DF ... annoGR2DF -> .local -> as.data.frame -> as.data.frame.default I have GenomicRanges listed in my Imports: field, and IRanges in the Suggests: of the DESCRIPTION file (it's require()d elsewhere). I'm trying to avoid putting packages in Depends: , so my package loads fast. Any tips of what I'm not understanding properly ? Thanks. -------------------------------------- Dario Strbenac Research Assistant Cancer Epigenetics Garvan Institute of Medical Research Darlinghurst NSW 2010 Australia
It would probably be helpful if you could point us to the source version of your package so that we can take a look what happens. Which version of R, and the other required packages are you talking about? Uwe Ligges On 15.04.2011 05:00, Dario Strbenac wrote:> I have a confusing error from R CMD check that I don't get when running the example manually by hand. > > In the \examples section of an Rd file, I create a GRanges object, then I call a function with the GRanges object, whose first 2 lines are > > require(GenomicRanges) > annoDF<- as.data.frame(anno) # anno is the GRanges object. > > and that second line gives: > > Error in as.data.frame.default(anno) : > cannot coerce class 'structure("GRanges", package = "GenomicRanges")' into a data.frame > Calls: annoGR2DF ... annoGR2DF -> .local -> as.data.frame -> as.data.frame.default > > I have GenomicRanges listed in my Imports: field, and IRanges in the Suggests: of the DESCRIPTION file (it's require()d elsewhere). I'm trying to avoid putting packages in Depends: , so my package loads fast. Any tips of what I'm not understanding properly ? > > Thanks. > > -------------------------------------- > Dario Strbenac > Research Assistant > Cancer Epigenetics > Garvan Institute of Medical Research > Darlinghurst NSW 2010 > Australia > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
On Apr 14, 2011, at 11:00 PM, Dario Strbenac wrote:> I have a confusing error from R CMD check that I don't get when running the example manually by hand. > > In the \examples section of an Rd file, I create a GRanges object, then I call a function with the GRanges object, whose first 2 lines are > > require(GenomicRanges)require() is doesn't guarantee that the package will load, so I think what you meant to write was more if (require(GenomicRanges, quietly=TRUE)) { ...> annoDF <- as.data.frame(anno) # anno is the GRanges object. > > and that second line gives: > > Error in as.data.frame.default(anno) : > cannot coerce class 'structure("GRanges", package = "GenomicRanges")' into a data.frame > Calls: annoGR2DF ... annoGR2DF -> .local -> as.data.frame -> as.data.frame.default > > I have GenomicRanges listed in my Imports: field, and IRanges in the Suggests: of the DESCRIPTION file (it's require()d elsewhere). I'm trying to avoid putting packages in Depends: , so my package loads fast. Any tips of what I'm not understanding properly ? > > Thanks. > > -------------------------------------- > Dario Strbenac > Research Assistant > Cancer Epigenetics > Garvan Institute of Medical Research > Darlinghurst NSW 2010 > Australia > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >
It turns out what I needed was IRanges in the Imports: field. I assumed that require(GenomicRanges) at the top of my function would, as a result of loading GenomicRanges, implicitly already know about all the IRanges classes, because GenomicRanges itself depends on them. ---- Original message ---->Date: Fri, 15 Apr 2011 20:34:54 -0700 >From: Martin Morgan <mtmorgan at fhcrc.org> >Subject: Re: [Rd] DESCRIPTION file and Rd examples >To: Simon Urbanek <simon.urbanek at r-project.org> >Cc: D.Strbenac at garvan.org.au, r-devel at r-project.org > >On 04/15/2011 11:18 AM, Simon Urbanek wrote: >> >> On Apr 14, 2011, at 11:00 PM, Dario Strbenac wrote: >> >>> I have a confusing error from R CMD check that I don't get when running the example manually by hand. >>> >>> In the \examples section of an Rd file, I create a GRanges object, then I call a function with the GRanges object, whose first 2 lines are >>> >>> require(GenomicRanges) >> >> require() is doesn't guarantee that the package will load, so I think what you meant to write was more >> >> if (require(GenomicRanges, quietly=TRUE)) { >> ... >> >>> annoDF<- as.data.frame(anno) # anno is the GRanges object. >>> >>> and that second line gives: >>> >>> Error in as.data.frame.default(anno) : >>> cannot coerce class 'structure("GRanges", package = "GenomicRanges")' into a data.frame >>> Calls: annoGR2DF ... annoGR2DF -> .local -> as.data.frame -> as.data.frame.default > >Try IRanges::as.data.frame(anno) > >I'm guessing that your call finds base::as.data.frame, perhaps because >some earlier example has already require'd GenomicRanges, and that it's >definition of as.data.frame has been masked some time in between. > >It's too complicated to debug in detail; R CMD check produces a file ><pkg>.Rcheck/<pkg>-Ex.R that contains the compiled example code, and it >is in the evaluation of this file that the error occurs. So you could >dissect it to discover the gory details. > >Martin > >>> >>> I have GenomicRanges listed in my Imports: field, and IRanges in the Suggests: of the DESCRIPTION file (it's require()d elsewhere). I'm trying to avoid putting packages in Depends: , so my package loads fast. Any tips of what I'm not understanding properly ? >>> >>> Thanks. >>> >>> -------------------------------------- >>> Dario Strbenac >>> Research Assistant >>> Cancer Epigenetics >>> Garvan Institute of Medical Research >>> Darlinghurst NSW 2010 >>> Australia >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>> >>> >> >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > >-- >Computational Biology >Fred Hutchinson Cancer Research Center >1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 > >Location: M1-B861 >Telephone: 206 667-2793-------------------------------------- Dario Strbenac Research Assistant Cancer Epigenetics Garvan Institute of Medical Research Darlinghurst NSW 2010 Australia