[R-pkg-devel] [External] Re: Confusing error
Since you have dplyr as a dependency (though I?d reconsider that one since
it can be quite hefty / change it?s API) I would suggest using
rlang::check_installer(?survey?) in the function that indirectly calls
survey.
This will throw an informative error when survey is not found.
In your examples you can wrap your example like:
if (rlang::is_installed(?survey?)) {
Example code here
}
On Mon, Dec 2, 2024 at 13:17 Cohen, Aaron <cohenaa at iu.edu> wrote:
Thank you [and Josiah Parry] for your help; I had already seen that PracTools uses `survey` but only suggests it, and I was unsure what to do on my end since I was getting in trouble whether I imported it or not. I will try doing what you suggest. Since the call to PracTools::deffCR is essential to this package, I will do the second suggestion. Best, Aaron From: Duncan Murdoch <murdoch.duncan at gmail.com> Date: Monday, December 2, 2024 at 3:48?PM To: Cohen, Aaron <cohenaa at iu.edu>, r-package-devel at r-project.org < r-package-devel at r-project.org> Subject: Re: [External] Re: [R-pkg-devel] Confusing error The PracTools::deffCR function calls survey::svydesign. It only suggests the survey package, so it is not necessarily available. What you could do is also suggest survey, then add a test for its presence before calling PracTools::deffCR. Or if that call is essential, then you should import survey, and add some innocuous direct reference to it to quiet the NOTE. Duncan Murdoch On 2024-12-02 3:38 p.m., Cohen, Aaron wrote:
Hello, thank you for getting back to me. I have a github with the code:
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F237triangle%2Fsurveynnet&data=05%7C02%7Ccohenaa%40iu.edu%7C060efca807ac4e2520f108dd13129edc%7C1113be34aed14d00ab4bcdd02510be91%7C0%7C0%7C638687692959141667%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=OH%2BsGWU%2FCuhyY111erhWCWNZE6rOsSnm2otRtrbN%2FaI%3D&reserved=0 <https://github.com/237triangle/surveynnet>
<
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F237triangle%2Fsurveynnet&data=05%7C02%7Ccohenaa%40iu.edu%7C060efca807ac4e2520f108dd13129edc%7C1113be34aed14d00ab4bcdd02510be91%7C0%7C0%7C638687692959178428%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=%2F4%2FhIYppugbVVzwyEsA1kAV5iK4XIUulxBOWmE1BZaI%3D&reserved=0 <https://github.com/237triangle/surveynnet>>
The main code is in R/surveynnet.R. Re: your suggestion, do you mean I should de-install the survey package? I will try that, but would appreciate any additional help in the meantime so I?m linking my github above. Best, Aaron *From: *Duncan Murdoch <murdoch.duncan at gmail.com> *Date: *Monday, December 2, 2024 at 3:09?PM *To: *Cohen, Aaron <cohenaa at iu.edu>, r-package-devel at r-project.org <r-package-devel at r-project.org> *Subject: *[External] Re: [R-pkg-devel] Confusing error [You don't often get email from murdoch.duncan at gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification <https://aka.ms/LearnAboutSenderIdentification> ] This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. On 2024-12-02 11:38 a.m., Cohen, Aaron wrote:
Hello, I am trying to submit an R package to CRAN. There are no notes,
comments or errors when checking on my local machine, but I keep getting an error message when submitting. I am attaching the log file, but basically the error occurs when running the examples. In particular, it says
Error in loadNamespace(x) : there is no package called 'survey' However, my package does not use the ?survey? package, and when I
include this package to the Imports field in the DESCRIPTION file, it gives the following NOTE:
checking dependencies in R code ... NOTE
Namespace in Imports field not imported from: ?survey?
All declared Imports should be used.
How do I resolve this issue?
I'd remove the survey package on your system, and try running the example that fails. If you get the same error, you can track it down. Duncan Murdoch
[[alternative HTML version deleted]]
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel