简体   繁体   中英

How to use a function from an external package in the example part of an R file

I am working on an R package and in the @examples part of my R file I call on ggplot from the ggplot2 package in my example code. I am not using any part of ggplot2 in my actual package code and so I wasn't sure how to call the ggplot2 functions.

Originally I thought I would just need to use ggplot2::ggplot() but the R CMD Check complained. So I added it to the Imports list in the DESCRIPTION file but then R complained that it shouldn't be in there since I am not using it in my code functions. I then thought to add it to using @import ggplot2 ggplot in my.R file but it seemed to complain about that as well.

Can anyone tell me how I should reference external functions in only the example part of my.R file? I tried reading through the R help pages on CRAN as well as Googling for an answer but I guess I wasn't able to find what I needed.

Packages used for examples only should be listed in 'Suggests:' instead of 'Imports:' in the DESCRIPTION file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM