Warning: replacing previous import ‘head’ when loading ‘utils’ in R
Asked Answered
E

2

20

When loading the RTextTools package from CRAN, I get the following warnings:

Warning messages:
1: replacing previous import ‘head’ when loading ‘utils’
2: replacing previous import ‘tail’ when loading ‘utils’

How do I get rid of these warnings? I'm the author of the package, so I can manipulate the source code; I'm looking for a solution that gets rid of the warnings rather than suppresses them. They seem to have appeared when I upgraded to R 2.14. Thank you in advance!

Exurbia answered 28/12, 2011 at 23:5 Comment(0)
H
26

This is not your issue - it's an issue in the glmnet package that you depend on: it explicitly imports all functions from both Matrix and utils but in the wrong order which causes a conflict since they both define head and tail (Matrix depends on utils so utils must be first). It is easy to fix - the order of imports has to be reversed in the glmnet/NAMESPACE but only the maintainer of glmnet can do that.

PS: This would be better asked on R-devel

Hostelry answered 29/12, 2011 at 1:54 Comment(1)
Thank you Simon! I'll redirect such questions to R-devel in the future.Exurbia
T
27

In general, this problem is often caused by having import(somepackage) in the namespace as well as importFrom(somepackage, somefunction).

Equivalently, using roxygen2, having both #' @import somepackage and #' @importFrom somepackage somefunction.

The best practice solution is to remove the import statement and keep only importFrom.

Trinity answered 22/7, 2014 at 9:55 Comment(0)
H
26

This is not your issue - it's an issue in the glmnet package that you depend on: it explicitly imports all functions from both Matrix and utils but in the wrong order which causes a conflict since they both define head and tail (Matrix depends on utils so utils must be first). It is easy to fix - the order of imports has to be reversed in the glmnet/NAMESPACE but only the maintainer of glmnet can do that.

PS: This would be better asked on R-devel

Hostelry answered 29/12, 2011 at 1:54 Comment(1)
Thank you Simon! I'll redirect such questions to R-devel in the future.Exurbia

© 2022 - 2024 — McMap. All rights reserved.