[Bioc-devel] Creating a package, Error in match.arg(units)

Martin Morgan mtmorgan at fhcrc.org
Mon Aug 31 20:15:19 CEST 2009


Sébastien Laigre wrote:
> Hi Martin,
> 
> Thank you for answering. I managed to solved my problem. In fact, it was
> a conflict between Hmisc and xtable. Hmisc overrided units from base
> package, and xtable needed it, so there was a problem. I used only 2
> functions, so I copied/pasted these 2 functions in my package, and do
> not use Hmisc. So the problem disapeared !

A better solution is to use a name space and 'importsFrom', for instance
in the DESCRIPTION file:

Imports: Hmisc

and in the NAMESPACE file

importFrom(Hmisc, someFunction, anotherFunction)

if you are not already using a name space, then I'd strongly encourage
you to use one. It'll help avoid conflicts like this in the future. Use
is documented in the 'Writing R extensions' manual.

Martin

> Thank you very much for your help.
> 
> 
> 2009/8/27 Martin Morgan <mtmorgan at fhcrc.org <mailto:mtmorgan at fhcrc.org>>
> 
>     Sébastien Laigre wrote:
>     > Hi Martin,
>     >
>     > I just saw that in install.out, there are the following lines :
>     >
>     >> Attachement du package : 'Hmisc'
>     >>
>     >>     The following object(s) are masked from package:base :
>     >>
>     >>      format.pval,
>     >>      round.POSIXt,
>     >>      trunc.POSIXt,
>     >>      units
>     >
>     > Then an error occurs with match.arg(units)...
>     >
>     > So, could it be a conflict between "units" of Hmisc package and
>     "units"
>     > of base package ?
>     > It sounds that units is taken from Hmisc instead of base, how can tell
>     > the compiler to take it into base package ? I tried with importFrom in
>     > NAMESPACE but it sounds it is not allowed...
> 
>     Your own package should have a name space, and if you use functions from
>     Hmisc you should import just those
> 
>     importFrom(Hmisc, foo, bar, baz)
> 
>     If you are importing from Hmisc, then the DESCRIPTION file should have
>     Imports: Hmisc. If there are still problems, you can fully qualify the
>     symbols that you want
> 
>      base::units
> 
>     It might be that there is still a problem, e.g., a third package that
>     does not have a name space but uses units, and so must find 'units' on
>     the search() path. In this case you must work around this by convincing
>     the third party author to use a name space, not use the third package,
>     or not use Hmisc.
> 
>     Martin
> 
>     >
>     > Thank you in advance.
>     >
>     > Sebastien
>     >
>     >
>     > 2009/8/26 Sébastien Laigre <sebastien.laigre at gmail.com
>     <mailto:sebastien.laigre at gmail.com>
>     > <mailto:sebastien.laigre at gmail.com
>     <mailto:sebastien.laigre at gmail.com>>>
>     >
>     >     Hi Martin,
>     >
>     >     Thank you for your suggestions. I tried once again with LazyLoad =
>     >     no (in DESCRIPTION file), and now, it tells me :
>     >
>     >     ...
>     >     Attachement du package : 'xtable'
>     >
>     >
>     >
>     >             The following object(s) are masked from package:Hmisc :
>     >
>     >              label,
>     >              label<-
>     >
>     >     Error in match.arg(units) :
>     >       'arg' doit Ûtre un de "secs", "mins", "hours", "days"
>     >     Error : impossible de charger le code R depuis le package 'MyApp'
>     >     Erreur : le chargement du package / espace de noms a ÚchouÚ
>     pour 'MyApp'
>     >     ExÚcution arrÛtÚe
>     >
>     >     It looks like this package has a loading problem: see the
>     messages for
>     >     details.
>     >
>     >     It sounds that a package could not be loaded correctly, but I can
>     >     not find which one. Is it the latest loaded (xtable) ? How can I
>     >     "load it correctly" ?
>     >     Thank you.
>     >
>     >     Sebastien
>     >
>     >
>     >
>     >
>     >     2009/8/26 Martin Morgan <mtmorgan at fhcrc.org
>     <mailto:mtmorgan at fhcrc.org> <mailto:mtmorgan at fhcrc.org
>     <mailto:mtmorgan at fhcrc.org>>>
>     >
>     >         Hi Sébastien --
>     >
>     >         Sébastien Laigre wrote:
>     >         > Hi Martin,
>     >         >
>     >         > Thank you for helping me.
>     >         > I just tried to create a new R session, but it doesn't
>     work so
>     >         much. I
>     >         > also tried to load files one by one using your 2 code lines,
>     >         but there
>     >         > are dependancies problems including files files ar not
>     loaded
>     >         in the
>     >         > right order.
>     >
>     >         it is not too hard to figure out how to load all the
>     packages, e.g.,
>     >         following the sequence listed in the 00install.out output,
>     below.
>     >
>     >         > In fact, I managed to check & build the package a few time
>     >         ago, but it
>     >         > doesn't work now. I had the right methodology, but I can't
>     >         know what has
>     >         > changed (sorry). My methodolgy is :
>     >         > 1. Create the package skeleton with package.build(...) in R
>     >         console.
>     >
>     >         Perhaps it would help to review the manual 'Writing R
>     Extensions' so
>     >         that you can get an understanding of what various files are?
>     >
>     >         > 2. Fill R documentation files in the man folder in skeleton,
>     >         NAMESPACE
>     >         > and DESCRIPTION files
>     >         > 3. Execute "Rcmd check c:/base/MyApp" with cmd.exe
>     (located in
>     >         R/bin folder)
>     >         > 4. Execute "Rcmd build c:/base/MyApp" with cmd.exe
>     (located in
>     >         R/bin folder)
>     >
>     >         Usually you want to do Rcmd build ... and then Rcmd check ....
>     >
>     >         Make sure that there are no 'hidden' files (starting with
>     a '.')
>     >         in any
>     >         of the folders in c:/base/MyApp/.
>     >
>     >         I don't really have other suggestions, other than to try to
>     >         narrow down
>     >         where in your package the error occurs, e.g., by temporarily
>     >         renaming
>     >         one file after the other in the MyApp/R directory.
>     >
>     >         Martin
>     >
>     >         > 5. Execute "Rcmd INSTALL MyApp.tar.gz" with cmd.exe (located
>     >         in R/bin
>     >         > folder)
>     >         >
>     >         > The error occurs when executing check command, here it
>     is the full
>     >         > install00.out :
>     >         >
>     >         > Le chargement a nécessité le package : tcltk
>     >         > Chargement de Tcl/Tk... terminé
>     >         > Le chargement a nécessité le package : Hmisc
>     >         > Attachement du package : 'Hmisc'
>     >         >
>     >         >     The following object(s) are masked from package:base :
>     >         >
>     >         >      format.pval,
>     >         >      round.POSIXt,
>     >         >      trunc.POSIXt,
>     >         >      units
>     >
>     >         > Le chargement a nécessité le package : R2HTML
>     >         > Le chargement a nécessité le package : svMisc
>     >         >
>     >         > *** 'hhc.exe' introuvable : l'aide CHM ne peut être générée
>     >         >
>     >         > * Installing *source* package 'MyApp' ...
>     >         > ** R
>     >         > ** preparing package for lazy loading
>     >         > Loading required package: grid
>     >         > Loading required package: reshape
>     >         > Loading required package: plyr
>     >         >
>     >         > Attaching package: 'plyr'
>     >         >
>     >         >     The following object(s) are masked from package:Hmisc :
>     >         >
>     >         >      is.discrete,
>     >         >      summarize
>     >         >
>     >         >
>     >         > Attaching package: 'ggplot2'
>     >         >
>     >         >     The following object(s) are masked from package:grid :
>     >         >
>     >         >      nullGrob
>     >         >
>     >         >
>     >         > Attaching package: 'xtable'
>     >         >
>     >         >     The following object(s) are masked from package:Hmisc :
>     >         >
>     >         >      label,
>     >         >      label<-
>     >         >
>     >         > Error in match.arg(units) :
>     >         >   'arg' should be one of "secs", "mins", "hours", "days"
>     >         > Error : unable to load R code in package 'MyApp'
>     >         > ERREUR : lazy loading failed pour le package 'MyApp'
>     >         > * Removing 'C:/PROGRA~1/R/R-29~1.1/bin/MYAPP~1.RCH/MyApp'
>     >         >
>     >         >
>     >         >
>     >         > Thank you again for you help.
>     >         >
>     >         >
>     >         >
>     >         > Sébastien
>     >         >
>     >         >
>     >         >
>     >         > 2009/8/25 Martin Morgan <mtmorgan at fhcrc.org
>     <mailto:mtmorgan at fhcrc.org>
>     >         <mailto:mtmorgan at fhcrc.org <mailto:mtmorgan at fhcrc.org>>
>     <mailto:mtmorgan at fhcrc.org <mailto:mtmorgan at fhcrc.org>
>     >         <mailto:mtmorgan at fhcrc.org <mailto:mtmorgan at fhcrc.org>>>>
>     >         >
>     >         >     Sébastien Laigre wrote:
>     >         >
>     >         >         Hello everybody,
>     >         >
>     >         >         I have got several S4 classes for my R application,
>     >         and I'm
>     >         >         trying to create
>     >         >         a package to deal it easier. It runs on windows XP.
>     >         >
>     >         >         So I make :
>     >         >
>     >         >           - a package.build(........) to build the
>     skeleton of
>     >         the package.
>     >         >           - Rcmd check c:/base/MyApp
>     >         >
>     >         >         But, checking whether package 'MyApp' can be
>     >         installed, I have
>     >         >         the following
>     >         >         error (in the install.out file) :
>     >         >         Error in match.arg(units) :
>     >         >          'arg' should be one of "secs", "mins", "hours",
>     "days"
>     >         >
>     >         >         I already encountered this kind error, and adding
>     >         >         "importFrom("package",
>     >         >         "function") " in the NAMESPACE file solved it.
>     >         >         But the match.arg function is in the base
>     package and
>     >         I can not
>     >         >         do that.
>     >         >
>     >         >         Can anyone help me please ? Does anybody knows what
>     >         can it be
>     >         >         due to ?
>     >         >
>     >         >
>     >         >     Have you tried to start a new R session
>     >         >
>     >         >      R --vanilla
>     >         >
>     >         >     and then source each of the files in the 'R'
>     directory of the
>     >         >     package, along the lines of
>     >         >
>     >         >      fls = list.files("c:/base/MyApp/R", full=TRUE)
>     >         >      for (f in fls) { cat(f, "\n"); source(f) }
>     >         >
>     >         >     ? Or can you provide more information about where
>     during the
>     >         >     installation the error message is generated? Please also
>     >         include
>     >         >     sessionInfo().
>     >         >
>     >         >     Martin
>     >         >
>     >         >
>     >         >         Thank you in advance.
>     >         >
>     >         >
>     >         >         Sebastien
>     >         >
>     >         >                [[alternative HTML version deleted]]
>     >         >
>     >         >         _______________________________________________
>     >         >         Bioc-devel at stat.math.ethz.ch
>     <mailto:Bioc-devel at stat.math.ethz.ch>
>     >         <mailto:Bioc-devel at stat.math.ethz.ch
>     <mailto:Bioc-devel at stat.math.ethz.ch>>
>     >         >         <mailto:Bioc-devel at stat.math.ethz.ch
>     <mailto:Bioc-devel at stat.math.ethz.ch>
>     >         <mailto:Bioc-devel at stat.math.ethz.ch
>     <mailto:Bioc-devel at stat.math.ethz.ch>>> mailing list
>     >         >         https://stat.ethz.ch/mailman/listinfo/bioc-devel
>     >         >
>     >         >
>     >         >
>     >         >     --
>     >         >     Martin Morgan
>     >         >     Computational Biology / Fred Hutchinson Cancer
>     Research Center
>     >         >     1100 Fairview Ave. N.
>     >         >     PO Box 19024 Seattle, WA 98109
>     >         >
>     >         >     Location: Arnold Building M1 B861
>     >         >     Phone: (206) 667-2793
>     >         >
>     >         >
>     >
>     >
>     >
> 
>



More information about the Bioc-devel mailing list