tomaszaba / ipccheckr

Toolkit for Performing IPC Acute Malnutrition-related Data Checks
GNU General Public License v3.0
2 stars 0 forks source link

Function to remove an imported function in NAMESPACE #9

Closed tomaszaba closed 3 months ago

tomaszaba commented 4 months ago

Hi @ernestguevarra, is there a handy package to edit NAMESPACE? More specifically to remove an imported function? I made a mistake of adding a base R function to NAMESPACE and now I'm getting this error:

image

Thanks

ernestguevarra commented 4 months ago

NAMESPACE shouldn't be edited by hand.

First thing to do is to remove any roxygen entry with @importFrom tag that imports the base function you are talking about. Once you have removed that, re-roxygenate your documentation by issuing the following command:

devtools::document()
tomaszaba commented 4 months ago

I did not edit by hand. I am editing using

usethis::use_import_from()

I review that tomorrow morning. Thanks for the help.

ernestguevarra commented 4 months ago

I did not edit by hand. I am editing using

usethis::use_import_from()

I review that tomorrow morning. Thanks for the help.

I never use that function and I've never had problems. I suggest that the only way to reverse what the function usethis::use_import_from() created is to delete it from the roxygen documenation.

Reading the documentation for this function, it says:

use_import_from() imports a function from another package by adding the roxygen2 ⁠@importFrom⁠ tag to the package-level documentation (which can be created with use_package_doc()). Importing a function from another package allows you to refer to it without a namespace (e.g., fun() instead of package::fun()).

I don't know if you already created a package level documentation (see my comment in another issue about this). I don't see an R file with the name ipccheckr-package.R in your R directory. This is what it refers to as package-level documentation. Without this, I am not sure where the usethis function places the @importFrom tag.

I would personally recommend not using the usethis function for this purpose. I always type this tag myself in my package-level documentation so that I have more control. the amount of characters you type to run the usethis funcdtion for this is the same amount of work to just document it directly yourself by typing it. I don't really see any convenience of using usethis for this purpose.