automated data analysis workflows
I have the following code in my packagename.R
file in the packagename
folder.
I know I am going to use certain functions from other packages routinely, so I want to import them once instead of typing them out all over the place. I thought I should be able to do that with the above approach, but it's not working in my RStudio.
#' packagename: Package containing tools support project work.
#'
#' This package provides a central repository for methods to facilitate
#' project work
#' @importFrom dplyr bind_rows mutate filter group_by ungroup
#' @importFrom purrr pluck map map_chr map_dbl
#' @importFrom lubridate ymd_hms
#' @importFrom odbc odbc
#' @importFrom DBI dbConnect dbDisconnect
#' @importFrom stringr str_detect str_replace_all
#' @docType package
#' @name packagename
NULL
In another file topic.R
I have:
do_thing <- function(x) str_replace_all(x, " ", "_"))
When I call do_thing
it tells me:
Error in str_replace_all(x, " ", "_") :
could not find function "str_replace_all"
Is there something more I need to add, or perhaps should I do something differently?
Based on the comments to the question, I needed to atleast regenerate my NAMESPACE
, which apparently was generated manually (since I started the project using the RStudio GUI), so roxygen
wouldn't update it. I am interested in how I can do this from the UI as well.
This is what my build menu looks like:
My NAMESPACE
file includes these imports but my test script still fails when trying to run the functions. Is this not possible as C. Braun suggests?