Reputation: 6874
I am trying to create a package. I use the ggplot2
library for one of the functions.
I have written the import statement for the function:
#' @param x the dataframe
#' @param Column the dataframe
#' @param Code the dataframe
#' @keywords Appointment filtering
#' @import ggplot2
#' @importFrom magrittr '%>%'
#' @importFrom dplyr arrange group_by summarise
#' @import rlang
#' @export
and written Imports:ggplot2
in the DESCRIPTION
as below
Package: MyPackage
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors@R: person("Sebastian", "Zeki", email = "[email protected]", role = c("aut", "cre"))
Description: What the package does (one paragraph).
Depends: R (>= 3.4.0)
Imports:
ggplot2
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
whenever I run load_all()
or document()
from the devtools I get the error:
Error in ggplot(....) :
could not find function "ggplot"
I have noticed that the NAMESPACE
file does not contain ggplot but does have the other imports present but when I add to the NAMESPACE
manually I get an error saying:
Error in importIntoEnv(pkgenv, exports, nsenv, exports) :
cannot add bindings to a locked environment
What have I missed?
Upvotes: 0
Views: 1355
Reputation: 6542
This is a feature in the devel version of devtools
.
You need to install it from github from a previous install : devtools::install_github("hadley/devtools")
Pkg loading mechanisms have been move to pkgload
. You can find this feature there. Pkgload
is loaded by devtools
so you don't need to bother.
Source for this answer:
It has been asked and answered in RStudio community forum by a rstudio team member.
Upvotes: 1