Including a single function from a package

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Including a single function from a package

Ken Kelley
Hello all.

I'm building a package where I want to include a function from two
different packages. In particular, I want to include mvrnorm and
hyperg_2F1 from MASS and gsl, respectively (but the specific functions
do not matter). With what I've tried after reading the "Specifying
imports and exports" section from the "Writing R Extensions" manual, I
get an error: "Namespace dependencies not required."

My NAMESPACE file consists of the following:
importFrom(MASS, mvrnorm)
importFrom(gsl, hyperg_2F1)
exportPattern("^[^\\.]")

A completely separate issue is that when running check, I get a warning
at the "checking S3 generic/method consistency" line that states:
"Warning: use of NULL environment is depreciated." I've looked at the
"Generic functions and methods" in the Writing R Extensions manual and
I'm still not sure what the "use of NULL environment is depreciated." I
suppose this is not a big deal, but it seems best not to have any warnings.


I'm sure I'm just missing something simple on both of these issues. Any
insight would be appreciated. I'm building the package with Win. XP.

Thanks,
Ken

--
Ken Kelley, Ph.D.
Indiana University
Inquiry Methodology Program
201 North Rose Avenue, Room 4040
Bloomington, Indiana 47405
(P/F) 812-856-8330 / 812-856-8333
http://www.indiana.edu/~kenkel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Including a single function from a package

Prof Brian Ripley
On Fri, 5 May 2006, Ken Kelley wrote:

> Hello all.
>
> I'm building a package where I want to include a function from two
> different packages. In particular, I want to include mvrnorm and
> hyperg_2F1 from MASS and gsl, respectively (but the specific functions
> do not matter). With what I've tried after reading the "Specifying
> imports and exports" section from the "Writing R Extensions" manual, I
> get an error: "Namespace dependencies not required."

When do you get the error?

> My NAMESPACE file consists of the following:
> importFrom(MASS, mvrnorm)
> importFrom(gsl, hyperg_2F1)
> exportPattern("^[^\\.]")

Does your DESCRIPTION file contain

Imports: MASS gsl

?

> A completely separate issue is that when running check, I get a warning
> at the "checking S3 generic/method consistency" line that states:
> "Warning: use of NULL environment is depreciated." I've looked at the
> "Generic functions and methods" in the Writing R Extensions manual and
> I'm still not sure what the "use of NULL environment is depreciated." I
> suppose this is not a big deal, but it seems best not to have any warnings.

It is a big deal: your code will fail in 2.4.0 and not be allowed on CRAN
now.  The message is probably not to do with that topic but to do with
loading your package.  So can you install and load the package without any
messages?

> I'm sure I'm just missing something simple on both of these issues. Any
> insight would be appreciated. I'm building the package with Win. XP.

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Including a single function from a package

Duncan Murdoch
In reply to this post by Ken Kelley
On 5/5/2006 8:42 AM, Ken Kelley wrote:

> Hello all.
>
> I'm building a package where I want to include a function from two
> different packages. In particular, I want to include mvrnorm and
> hyperg_2F1 from MASS and gsl, respectively (but the specific functions
> do not matter). With what I've tried after reading the "Specifying
> imports and exports" section from the "Writing R Extensions" manual, I
> get an error: "Namespace dependencies not required."
>
> My NAMESPACE file consists of the following:
> importFrom(MASS, mvrnorm)
> importFrom(gsl, hyperg_2F1)
> exportPattern("^[^\\.]")

I don't see this in a quick test in the current R-patched.

> A completely separate issue is that when running check, I get a warning
> at the "checking S3 generic/method consistency" line that states:
> "Warning: use of NULL environment is depreciated." I've looked at the
> "Generic functions and methods" in the Writing R Extensions manual and
> I'm still not sure what the "use of NULL environment is depreciated." I
> suppose this is not a big deal, but it seems best not to have any warnings.

It indicates a bug somewhere or other, but the version of R you're using
(you didn't say) is willing to work around it for now.  The next version
will not.

 From the location where you saw the error, it looks like a bug in R
rather than in your code, but surely such a thing would have been seen
before.  Are you using an unreleased version?

This may also explain the problems with your namespace file.

Duncan Murdoch
>
>
> I'm sure I'm just missing something simple on both of these issues. Any
> insight would be appreciated. I'm building the package with Win. XP.
>
> Thanks,
> Ken
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Including a single function from a package

Ken Kelley
In reply to this post by Prof Brian Ripley
Thank you both very much for your quick and helpful responses.

I added "Imports: MASS, gsl" to the DESCRIPTION file and that took care
of loading in the desired functions just fine. I went back and took
another look at the "Specifying imports and exports" section (section
1.6.1) of the Writing R Extensions manual and I do not see anything
about including an "Imports:" line in the DESCRIPTION file when
including an "importFrom" in the NAMESPACE file. Perhaps including this
information in a future update should be considered.

I was building the package on a machine that had a pre-release version
of R 2.3.0 (from some time ago). After updating to the released version
of 2.3, the warning about a "depreciated NULL environment" did not occur
and the package built just fine.

Thanks again and have a good day,
Ken


Prof Brian Ripley wrote:

> On Fri, 5 May 2006, Ken Kelley wrote:
>
>> Hello all.
>>
>> I'm building a package where I want to include a function from two
>> different packages. In particular, I want to include mvrnorm and
>> hyperg_2F1 from MASS and gsl, respectively (but the specific functions
>> do not matter). With what I've tried after reading the "Specifying
>> imports and exports" section from the "Writing R Extensions" manual, I
>> get an error: "Namespace dependencies not required."
>
>
> When do you get the error?
>
>> My NAMESPACE file consists of the following:
>> importFrom(MASS, mvrnorm)
>> importFrom(gsl, hyperg_2F1)
>> exportPattern("^[^\\.]")
>
>
> Does your DESCRIPTION file contain
>
> Imports: MASS gsl
>
> ?
>
>> A completely separate issue is that when running check, I get a warning
>> at the "checking S3 generic/method consistency" line that states:
>> "Warning: use of NULL environment is depreciated." I've looked at the
>> "Generic functions and methods" in the Writing R Extensions manual and
>> I'm still not sure what the "use of NULL environment is depreciated." I
>> suppose this is not a big deal, but it seems best not to have any
>> warnings.
>
>
> It is a big deal: your code will fail in 2.4.0 and not be allowed on
> CRAN now.  The message is probably not to do with that topic but to do
> with loading your package.  So can you install and load the package
> without any messages?
>
>> I'm sure I'm just missing something simple on both of these issues. Any
>> insight would be appreciated. I'm building the package with Win. XP.
>
>

--
Ken Kelley, Ph.D.
Indiana University
Inquiry Methodology Program
201 North Rose Avenue, Room 4040
Bloomington, Indiana 47405
(P/F) 812-856-8330 / 812-856-8333
http://www.indiana.edu/~kenkel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Including a single function from a package

Prof Brian Ripley
On Fri, 5 May 2006, Ken Kelley wrote:

> Thank you both very much for your quick and helpful responses.
>
> I added "Imports: MASS, gsl" to the DESCRIPTION file and that took care of
> loading in the desired functions just fine. I went back and took another look
> at the "Specifying imports and exports" section (section 1.6.1) of the
> Writing R Extensions manual and I do not see anything about including an
> "Imports:" line in the DESCRIPTION file when including an "importFrom" in the
> NAMESPACE file. Perhaps including this information in a future update should
> be considered.

Well, no, it described under the DESCRIPTION file:

   The optional @samp{Imports} field lists packages whose namespaces are
   imported from but which do not need to be attached.

Note that caveat which complicates the issue and I think makes in
inappropriate for that section.

> I was building the package on a machine that had a pre-release version of R
> 2.3.0 (from some time ago). After updating to the released version of 2.3,
> the warning about a "depreciated NULL environment" did not occur and the
> package built just fine.
>
> Thanks again and have a good day,
> Ken
>
>
> Prof Brian Ripley wrote:
>> On Fri, 5 May 2006, Ken Kelley wrote:
>>
>>> Hello all.
>>>
>>> I'm building a package where I want to include a function from two
>>> different packages. In particular, I want to include mvrnorm and
>>> hyperg_2F1 from MASS and gsl, respectively (but the specific functions
>>> do not matter). With what I've tried after reading the "Specifying
>>> imports and exports" section from the "Writing R Extensions" manual, I
>>> get an error: "Namespace dependencies not required."
>>
>>
>> When do you get the error?
>>
>>> My NAMESPACE file consists of the following:
>>> importFrom(MASS, mvrnorm)
>>> importFrom(gsl, hyperg_2F1)
>>> exportPattern("^[^\\.]")
>>
>>
>> Does your DESCRIPTION file contain
>>
>> Imports: MASS gsl
>>
>> ?
>>
>>> A completely separate issue is that when running check, I get a warning
>>> at the "checking S3 generic/method consistency" line that states:
>>> "Warning: use of NULL environment is depreciated." I've looked at the
>>> "Generic functions and methods" in the Writing R Extensions manual and
>>> I'm still not sure what the "use of NULL environment is depreciated." I
>>> suppose this is not a big deal, but it seems best not to have any
>>> warnings.
>>
>>
>> It is a big deal: your code will fail in 2.4.0 and not be allowed on CRAN
>> now.  The message is probably not to do with that topic but to do with
>> loading your package.  So can you install and load the package without any
>> messages?
>>
>>> I'm sure I'm just missing something simple on both of these issues. Any
>>> insight would be appreciated. I'm building the package with Win. XP.
>>
>>
>
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Including a single function from a package

Seth Falcon-2
Prof Brian Ripley <[hidden email]> writes:

> On Fri, 5 May 2006, Ken Kelley wrote:
>
>> Thank you both very much for your quick and helpful responses.
>>
>> I added "Imports: MASS, gsl" to the DESCRIPTION file and that took care of
>> loading in the desired functions just fine. I went back and took another look
>> at the "Specifying imports and exports" section (section 1.6.1) of the
>> Writing R Extensions manual and I do not see anything about including an
>> "Imports:" line in the DESCRIPTION file when including an "importFrom" in the
>> NAMESPACE file. Perhaps including this information in a future update should
>> be considered.
>
> Well, no, it described under the DESCRIPTION file:
>
>    The optional @samp{Imports} field lists packages whose namespaces are
>    imported from but which do not need to be attached.
>
> Note that caveat which complicates the issue and I think makes in
> inappropriate for that section.

I think it would be an improvement to mention in the namespace
documentation that imported package must appear in either Depends or
Imports in the DESCRIPTION file as well as being mentioned in the
NAMESPACE file.  The requirment that this information be repeated is
not obvious to many.  That is, one might reasonably imagine that
specifying imports with an importsFrom directive in the NAMESPACE file
is enough.

+ seth

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Including a single function from a package

Martin Maechler
>>>>> "Seth" == Seth Falcon <[hidden email]>
>>>>>     on Fri, 05 May 2006 07:56:02 -0700 writes:

    Seth> Prof Brian Ripley <[hidden email]> writes:
    >> On Fri, 5 May 2006, Ken Kelley wrote:
    >>
    >>> Thank you both very much for your quick and helpful
    >>> responses.
    >>>
    >>> I added "Imports: MASS, gsl" to the DESCRIPTION file and
    >>> that took care of loading in the desired functions just
    >>> fine. I went back and took another look at the
    >>> "Specifying imports and exports" section (section 1.6.1)
    >>> of the Writing R Extensions manual and I do not see
    >>> anything about including an "Imports:" line in the
    >>> DESCRIPTION file when including an "importFrom" in the
    >>> NAMESPACE file. Perhaps including this information in a
    >>> future update should be considered.
    >>  Well, no, it described under the DESCRIPTION file:
    >>
    >> The optional @samp{Imports} field lists packages whose
    >> namespaces are imported from but which do not need to be
    >> attached.
    >>
    >> Note that caveat which complicates the issue and I think
    >> makes in inappropriate for that section.

    Seth> I think it would be an improvement to mention in the
    Seth> namespace documentation that imported package must
    Seth> appear in either Depends or Imports in the DESCRIPTION
    Seth> file as well as being mentioned in the NAMESPACE file.
    Seth> The requirment that this information be repeated is
    Seth> not obvious to many.  That is, one might reasonably
    Seth> imagine that specifying imports with an importsFrom
    Seth> directive in the NAMESPACE file is enough.

I do have to agree with Seth;
I've helped several people now all of whom had problems with the
above when they were told to follow work along the documentation
in "Writing R Extensions".
The typical package writer will start with

DESCRIPTION, R/*.R, then, man/*.Rd, etc  
and at some point learn about NAMESPACE and read in the manual
about things related to the "new NAMESPACE".  It's very natural
*not* go back and reread the docu about DESCRIPTION as well.

Martin

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel