[R] header files for R packages

Romain Francois romain.francois at dbmail.com
Sun Jan 24 08:59:39 CET 2010


On 01/24/2010 04:37 AM, David Lubbers wrote:
>
> I have 6 or 7 nice constants (for example 1852 meters per nautical mile)
> I would like to have available to 4 or 5 functions in an R package.   In
> C this would just be a header .h file and I would just "include"  I am
> stuck trying to figure out how to create something like a C header file
> for an R package.  Any ideas?

Hi,

If your package has a namespace, it is easy. If not, add one.

Just create the "constants" in one of your R files within the package. 
that's it. If you don't export the constant, that is all you really need.

Otherwise, you can lock the binding using lockBinding, but this is not 
full proof as one can still remove the variable and recreate it ... it 
just makes it harder to modify, but not impossible

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009



More information about the R-help mailing list