Export package

Asked

Viewed 67 times

2

Guys I created a package in the R, already with the documentation, with the @export in each role, I ask for the Rstudio create the package and all right. But when I import the package it reads all the documents, helps of all functions, but does not properly read the function. That is to say, ?funcao functioned, but funcao(x) says that it did not find the function.

Issue 1.

Being precise, it’s like this, I have the functions within the NAMESPACE created by roxygen2 thus:

S3method(plot,polygon)
export(convex.verification)
export(polygon.intersection)
export(polygon.transformation)
export(polygonal.correlation)
export(polygonal.covariance)
export(polygonal.mean)

And the function that is not recognized at check is just the plot.polygon

Does anyone have any idea what it is?

  • 2

    see if NAMESPACE has the name of all functions, this file controls what appears and what does not.

  • 2

    As always, Hadley’s chapter on NAMESPACE explains very well what it is, how it works and why it exists, and gives several tips. http://r-pkgs.had.co.nz/namespace.html

  • 2

    Also make sure you used the right syntax from Roxygen2 notation (#' @export just before the definition of the function).

  • 1

    I found the mistake, it’s in roxygen2 is installing with error, I tried to reinstall, but will not, appears the message: Warning in install.packages : cannot remove prior installation of package roxygen2.

  • 1

    Usually if you restart your computer this problem of removing the package installation is fixed. This happens often because you have some R session using the folder. But the NAMESPACE I was really wrong?

  • 1

    Yes, when check, it asks for a function called hello that does not exist in the package and aborts, but runs all documentation just that functions remain non-existent.

  • 1

    And a function that exists is not recognized.

  • 1

    I edited adding more information.

  • I don’t know much about S3Methods, but I think the problem is there. Their idea is that they work without using Plot.Polygon, that it would just be plot on a Polygon class object. I don’t know if roxygen2 follows this idea and stops exporting the function normally.

  • Have you ever tried to use alone plot in an object with class polygon?

  • Tried, gives error. This function plots several overlapping polygons connecting the points.

Show 7 more comments

1 answer

1


According to the book R-Packages

Object Names Variable and Function Names should be lowercase. Use an underscore (_) to Separate words Within a name (reserve . for S3 methods). Camel case is a legitimate Alternative, but be consistent! Generally, variable Names should be nouns and Function Names should be Verbs. Strive for Names that are Concise and Meaningful (this is not easy!).

I highlight the phrase:

Use an underscore (_) to Separate words Within a name (reserve . for S3 methods).

That is to say: Use underline (_) to separate words in the name (.. of an object) (reserve . for S3 methods).

I don’t know exactly how S3 works and how roxygen2 behaves in his presence. My guess is that it doesn’t export the function, only the method. Therefore, its function might function on an object with class polygon.

Example:

class(obj) <- "polygon"
plot(obj)

If that’s not what you want, try replacing the point in the function name with underline (_).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.