Namespace in Imports field not imported from: ‘methods’

856 views
Skip to first unread message

Timothy Bates

unread,
Aug 21, 2015, 5:22:46 AM8/21/15
to devtools
Hi,
I use the methods package in my package to set a class

So, in DESCRIPTION, I have
    Imports:
        methods

And where I call functions from methods, I use the :: syntax, e.g.:

    methods::setClass("MxModel.ACE", contains = "MxModel")


But on check(), I get this error

* checking dependencies in R code ... NOTE
Namespace in Imports field not imported from: methods
 All declared Imports should be used.

Any clues?

packageVersion("roxygen2")
[1] 4.1.1
packageVersion
("devtools")
[1] 1.9.0



Hadley Wickham

unread,
Aug 21, 2015, 7:47:54 AM8/21/15
to Timothy Bates, devtools
It's because methods::setClass is called during the build process, so
it's not actually included in the package source code. It's a spurious
warning, so just suppress with a spurious importFrom in the namespace,
e.g. # @importFrom methods new

Hadley
> --
> You received this message because you are subscribed to the Google Groups
> "devtools" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rdevtools+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
http://had.co.nz/

Timothy Bates

unread,
Aug 21, 2015, 8:32:31 AM8/21/15
to devtools
gotcha: Thanks again!

It might be helpful to include these "spurious CRAN NOTE" fixes in the devtools wiki/book.

I could not see a direct fix in stackoverflow, though people were clearly having similar problems.

Reply all
Reply to author
Forward
0 new messages