2

Starting Situation:

I'm writing a small package of functions for myself only (not CRAN; on GitHub, but not public), and developing locally on the computer. Mostly this is me being a newbie at R and learning to write first package.

I'm using devtools and after load_all() and check(), I have been getting this "NOTE":

-- R CMD check results -------------------------------------------------------------------------------------------- MondelezR 0.1.0 ----
Duration: 21.1s

> checking dependencies in R code ... NOTE
  Namespace in Imports field not imported from: 'tibble'
    All declared Imports should be used.

0 errors v | 0 warnings v | 1 note x

Question:

Am I doing something wrong or is this a known/ expected problem that I can ignore?

Little more background:

I am using tibble()

In my package, "Find in Files" shows that I have used tibble in four files in different ways:

DESCRIPTION file:

[First Section of File Omitted]
Encoding: UTF-8
RoxygenNote: 7.2.0
Imports: 
    stringr,
    dplyr,
    purrr,
    tibble,
    magrittr
Suggests: 
    testthat (>= 3.0.0)
Config/testthat/edition: 3

(I have not seen the message for the other imported packages.)

FUNCTION: mdlz_otm_filter.R

[omitted]
#' @examples
#' df_otm_final <- tibble::tibble(
[omitted]

I am only using tibble in the example, not in the function itself, and the relevant portion is shown above.

DOCUMENTATION: mdlz_otm_filter.Rd

The roxygen2 documentation created from the above function shows the exact same example, but as documentation.

TEST THAT: test-mdlz_make_KEY1.R

test_that("POSTAL LANE2 works as expected", {

  df_test <- tibble::tibble(ORIG_ZIP = c("18615", "12345", "a5J 1u8"),
                            DEST_ZIP = c("1234", "23456", "i9y2b4"),
                            FINAL_KEY = c("18615-01234","12345-23456","A5J1U8-I9Y2B4"))

  expect_identical(mdlz_make_POSTAL_LANE(df_test$ORIG_ZIP,
                                         df_test$DEST_ZIP),
                   df_test$FINAL_KEY)
})

Attempt to remove tibble from DESCRIPTION

I tried removing tibble from Imports: on the DESCRIPTION file, but as I expected would happen, I got this instead:

-- R CMD check results -------------------------------------------------------------------------------------------- MondelezR 0.1.0 ----
Duration: 26.6s

> checking for unstated dependencies in examples ... WARNING
  '::' or ':::' import not declared from: 'tibble'

> checking for unstated dependencies in 'tests' ... WARNING
  '::' or ':::' import not declared from: 'tibble'

0 errors v | 2 warnings x | 0 notes v

So... warnings are worse than notes I figure.

Research:

Google search to start with brought me to these posts:

RStudio Community Meta-Package This guy's problem is that he needs to use functions in every package he's trying to put in his meta-package. My issue is I'm already using tibble and getting the note regardless.

SO devtools R CMD check NOTE But this one doesn't seem to apply because I AM using tibble in my package, and this guy is trying to remove it.

Help?

I don't know how to clear the note, if I should worry about it at all, or why I'm getting it since I am using tibble as shown above. Trying to learn, so an expository answer is appreciated. Thank you in advance.

Phil
  • 7,287
  • 3
  • 36
  • 66
ScottyJ
  • 945
  • 11
  • 16
  • It likely means you have `tibble` in `Imports:` in `DESCRIPTION`, but are not actually importing it in `NAMESPACE`. If you only use it in tests, you could move it from `Imports:` to `Suggests:` (but should condition its use in tests via `if (requireNamespace("tibble", quietly=TRUE)) ....`) – Dirk Eddelbuettel Jul 03 '22 at 01:05
  • You're right, it wasn't in `NAMESPACE`. I added `#' @importFrom tibble "tibble"` and then `load_all()` and `check()` and it is now cleared because it has been added to `NAMESPACE`, but I don't understand why I need this for `tibble` and not for the other packages I'm using, like `dplyr` or `stringr`. I think you're suggesting that my use in tests is treated differently than when I use it directly in functions I'm writing (?). And examples are a different beast? I'll go read some more.... thank you. – ScottyJ Jul 03 '22 at 01:45

1 Answers1

0

It seems devtools check function is looking for an importFrom tag with the package tibble in some of your function documentation roxygen Docs.

Adding @importFrom tibble tibble to the functions documentation which use the library tibble might remove the note.