indexthis_vendor {indexthis}R Documentation

Vendor the to_index function

Description

Utility to integrate the to_index function within a package without a dependency.

Usage

indexthis_vendor(pkg = ".")

Arguments

pkg

Character scalar, default is ".". Location of the package directory where the files will be created.

Details

This is a utility to populate a package with the necessary code to run the to_index function. This avoids to create a dependency with the indexthis package.

The underlying code of to_index is in C++. Hence if the routines are to be included in a package, it needs to be registered appropriately. There are four cases: three are automatic, one requires a bit of copy pasting from the user. Let's review them.

It the target package already has C++ code and uses Rcpp or cpp11 to make the linking, the function indexthis_vendor registers the main function as a Rcpp or cpp11 routine, and all should be well.

If the target package has no C/C++ code at all, indexthis_vendor updates the NAMESPACE and registers the routine, and all should be well.

If the target package already has C/C++ code, this is more coplicated because there should be only one R_init_pkgname symbol and it should be existing already (see Writing R extensions, section "dyn.load and dyn.unload"). In that case, in the file to_index.cpp the necessary code to register the routine will be at the end of the file, within comments. The (knowledgeable) user has to copy paste in the appropriate location, where she registers the existing routines.

Value

This function does not return anything. Instead it writes two files: one in R (by default in the folder ./R) and one in cpp (by default in the folder ⁠src/⁠). Those files contain the necessary source code to run the function to_index.

Examples


## DO NOT RUN: otherwise it will write in your packge workspace
# indexthis_vendor()


[Package indexthis version 2.1.0 Index]