Using roxygen2
to generate namespace
is completely new to me. Some related questions have been asked and answered multiple times as well as http://r-pkgs.had.co.nz/namespace.html. I still find it difficult for me. I definitely need to read more on this topic. Meanwhile, I just wonder if someone could offer a simple example of code to quickly get me into it first.
I'm not sure the following information will help. I have several functions in the package. The DESCRIPTION
includes something like:
Imports:
dplyr,
ggplot2,
survival
Thanks,
Try to create a function within the R folder of you package.
Something like
#' Function to plot something
#'
#' @param my_data a data frame
#' @param x column name for x axis
#' @param y column name for y axis
#' @export
#' @import ggplot2
#' @examples
#' plotSomething(iris, 'Sepal.Length', 'Sepal.Width')
plotSomething <- function(my_data, x, y) {
ggplot(my_data, aes_string(x=x, y=y)) + geom_point()
}
The keywords @export
and @import
will be parsed by roxygen2
and will update the NAMESPACE
file after using devtools::document()
.