Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.4%) to scientific vocabulary
Keywords
Repository
Tidy C++ wrapping of the C API of R
Basic Info
Statistics
- Stars: 40
- Watchers: 4
- Forks: 3
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
tidyCpp: Tidy C++ wrapping of the C API for R
About
The C API of the R language and environment is robust, yet a little awkward for C++ programmers. This package wraps a tidy layer of header functions around it.
R Core is moving towards a more explicit classification of which functions are officially part of the API for R, and which ones are 'experimental'. A very helpful contributed page summarizes the status.
Examples
A recent motivating example is from the dang package which includes one unexported Base R function written in C. The original version is here. While short enough, we found working with a tidier version easier and more enjoyable. We include an abbreviated version (minus the copyright header) here:
```c++
include
extern "C" {
// cf src/library/tools/src/text.c SEXP checknonASCII(SEXP text, SEXP ignorequotes) { /* Check if all the lines in 'text' are ASCII, after removing comments and ignoring the contents of quotes (unless ignorequotes) (which might span more than one line and might be escaped).
This cannot be entirely correct, as quotes and \ might occur as
part of another character in a MBCS: but this does not happen
in UTF-8.
*/
int i, nbslash = 0; /* number of preceding backslashes */
const char *p;
char quote= '\0';
Rboolean ign, inquote = FALSE;
if (!R::isString(text)) R::error("invalid input");
ign = (Rboolean) R::asLogical(ignore_quotes);
if (ign == NA_LOGICAL) R::error("'ignore_quotes' must be TRUE or FALSE");
for (i = 0; i < R::length(text); i++) {
p = R::charPointer(R::stringElement(text, i)); // ASCII or not not affected by charset
inquote = FALSE; /* avoid runaway quotes */
for (; *p; p++) {
if (!inquote && *p == '#') break;
if (!inquote || ign) {
if ((unsigned int) *p > 127) {
Rprintf("%s\n", R::charPointer(R::stringElement(text, i)));
Rprintf("found %x\n", (unsigned int) *p);
return R::scalarLogical(TRUE);
}
}
if ((nbslash % 2 == 0) && (*p == '"' || *p == '\'')) {
if (inquote && *p == quote) {
inquote = FALSE;
} else if(!inquote) {
quote = *p;
inquote = TRUE;
}
}
if (*p == '\\') nbslash++; else nbslash = 0;
}
}
return R::scalarLogical(FALSE);
}
} // extern "C" ```
Additions from the tidyCpp wrapper can be identified easily via the R:: namespace. While the
code is not hiding its C heritage, we find it overall a little easier to work with. Other examples
(see below) show how using tidyCpp can help avoid the very manual and error-prone PROTECT and
UNPROTECT and pairs.
For additional examples, please see the Motivation vignette for a longer discussion with more examples, and the files in the snippets/ directory for directly callable code examples.
Author
Dirk Eddelbuettel
License
GPL (>= 2)
Owner
- Name: Dirk Eddelbuettel
- Login: eddelbuettel
- Kind: user
- Location: Chicago, IL, USA
- Website: https://dirk.eddelbuettel.com
- Twitter: eddelbuettel
- Repositories: 512
- Profile: https://github.com/eddelbuettel
GitHub Events
Total
- Watch event: 1
- Push event: 1
Last Year
- Watch event: 1
- Push event: 1
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Dirk Eddelbuettel | e****d@d****g | 73 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 1
- Average time to close issues: 2 days
- Average time to close pull requests: 9 minutes
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 2.0
- Average comments per pull request: 3.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- romainfrancois (1)
Pull Request Authors
- romainfrancois (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 381 last-month
- Total docker downloads: 48
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 7
- Total maintainers: 1
cran.r-project.org: tidyCpp
Tidy C++ Header-Only Definitions for Parts of the C API of R
- Homepage: https://github.com/eddelbuettel/tidycpp
- Documentation: http://cran.r-project.org/web/packages/tidyCpp/tidyCpp.pdf
- License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
-
Latest release: 0.0.7
published about 2 years ago
Rankings
Maintainers (1)
Dependencies
- Rcpp * suggests
- RcppSpdlog * suggests
- simplermarkdown * suggests
- actions/checkout v3 composite