Rpackage: Rstudio possibly generating bad NAMESPACE file

Cauchy

I am making an R package in Rstudio and I selected the option Configure Build Tools > Configure and select Use roxygen to generate NAMESPACE. I wrote my functions in Rcpp and this is what the NAMESPACE looks like when I generate it with roxygen2:

# Generated by roxygen2 (4.1.1): do not edit by hand

export(function1)
export(function2)
export(function3)
export(function4)

Since my functions are written with Rcpp, which I then export, then they will used in R via .Call. However, from writing R extensions we should use useDynLib() in such a case. This is why I think I am getting an error when I try to call function1 and the error is:

Error in .Call("Mypackage_function1", PACKAGE = "Mypackage", var1,  : 
"Mypackage_function1" not available for .Call() for package "Mypackage"

When I use the default NAMESPACE when I start a project in Rstudio, I have the following in NAMESPACE:

useDynLib(packagename)
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp, evalCpp)

When I use the default NAMESPACE I can call the functions using .Call however I get a warning when I check the package that I am not generating the NAMESPACE using roxygen.

Is there a fix for this? Any advice is appreciated.

Konrad Rudolph

This is unrelated to the usage of RStudio: For Roxygen to generate the relevant useDynLib specification, you need to use the @useDynLib tag in a Roxygen doc comment:

#' @useDynLib packagename

You can do this anywhere (where you can use normal Roxygen comments) but it makes sense to put this into the package documentation, rather than the documentation of a specific function. Usually this resides in a file called R/packagename-package.r:

#' My package documentation
#' … bla bla …
#' @name packagename
#' @docType package
#' @useDynLib packagename
NULL

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rpackage: Rstudio possibly generating bad NAMESPACE file

From Dev

Pandoc for generating html file not using RStudio

From Dev

Rstudio not generating .Rd files

From Dev

Bad characters when generating pdf file with Knp Snappy

From Dev

Javascript file resizing generating bad base64 string

From Dev

RazorGenerator not generating the correct namespace

From Dev

Is a static pointer marked as possibly lost block bad?

From Dev

Haskell : unexpected ´;' possibly due to bad layout

From Dev

Hibernate generating bad syntax sql

From Dev

Eloquent ORM is generating a bad query

From Dev

Eloquent ORM is generating a bad query

From Dev

Generating pander tables in a loop in RMarkdown in Rstudio

From Dev

Generating LaTeX tables instead of text in Rstudio

From Dev

Generating all possibly length n combinations of two items in python

From Dev

Why am I getting “namespace is locked” in RStudio?

From Dev

Why am I getting “namespace is locked” in RStudio?

From Dev

Generating XSD from XML and add namespace XSLT

From Dev

IE (or possibly Javascript library) Adding SVG namespace twice

From Dev

"Origin" must be supplied issue with the function in r: possibly environment/namespace issue

From Dev

RStudio R File Corruption

From Dev

How to detect and possibly ignore processing a bad/hung client browser request

From Dev

Bad request error when generating services

From Java

gcov not generating gcda file

From Dev

apxs Not Generating .so file?

From Dev

Generating WAV File Tones

From Dev

Generating a .so file with Autotools

From Dev

Generating a file path

From Dev

apktool is not generating apk file

From Dev

CSRFTester not generating html file

Related Related

HotTag

Archive