r-package

Building R packages (C API) with Visual Studio

北战南征 提交于 2019-12-10 17:54:16
问题 I'm trying to build a simple R package with Visual Studio, here is my code: #include <R.h> #include <Rinternals.h> SEXP add(SEXP a, SEXP b) { SEXP result = PROTECT(allocVector(REALSXP, 1)); REAL(result)[0] = asReal(a) + asReal(b); UNPROTECT(1); return result; } I have R runtime and RTools installed. When I try to compile it, I get the following link error: error LNK2019: unresolved external symbol REAL referenced in function "struct SEXPREC * __cdecl add(struct SEXPREC *,struct SEXPREC *)" (

Why doesn't my package function find other non-export tagged functions?

耗尽温柔 提交于 2019-12-10 17:35:40
问题 I've read most of Hadley Wickham's great book: http://r-pkgs.had.co.nz/, but I'm confused as to why my functions within my package can't find my other non-exported functions. E.g I have #' @export #' @import ggmap #' @import hexbin map <- function(return.query, zoom, maptype, histObj) { UseMethod("map") } #' map.querySold <- function(query, zoom = 11, maptype = "roadmap") { My Code } Running this with a clean enviroment and loading my package generates error: > map(x) # x is of class

R package: writing internal data, but not all at once

早过忘川 提交于 2019-12-10 16:01:33
问题 I'm working on an R package using usethis / devtools . The package has a few objects I'd like to keep internal, just to keep down the clutter. The structure I was using was to make objects in different files based on their source, all in my data-raw folder. For instance, the file make_laus_codes.R preps two data frames of lookup codes from the Bureau of Labor Statistics (one internal, called laus_codes ), and the file make_decennial_tables.R preps lookup codes from the Decennial Census

CRAN submission - R CMD Check warning - compilation flags used

南笙酒味 提交于 2019-12-10 14:35:12
问题 I am trying to submit my first package to CRAN and on my machine, I am getting the following warning on running R CMD check (via RStudio ) checking compilation flags used ... WARNING Compilation used the following non-portable flag(s): ‘-Wno-unused-function’ ‘-Wno-unused-variable’ including flag(s) suppressing warnings R CMD check results 0 errors | 1 warning | 0 notes R CMD check succeeded I don't get this warning on building my package on R win-builder. I do get a NOTE from the win-builder

Package build ignores Makevars flags

别来无恙 提交于 2019-12-10 13:23:41
问题 Question I'm trying to tell my package to use gcc to compile the C++ code in stead of clang . Why aren't my CXX flags in my Makevars file being used? (I am expecting/hoping the solution to be something really simple that I've overlooked.) It's my understanding (see references ) that I can specify CXX* flags in either src/Makevars in the package, or ~/.R/Makevars However, I can't get option 1 to work, only option 2. Example Builds Here are screenshots showing the build options I'm using. In

Exporting an unwieldy set of constants in a package

折月煮酒 提交于 2019-12-10 11:25:36
问题 I have a package with a nontrivial list of constants I'd like to export to be available to users who load the package. What's the right way of doing so? The only way I came up with that does what I want is to define the constants in the R code: a = 1 # (no worries, I'm not using such silly names for the constants) b = 2 ... z = 26 Then make sure to export them in the NAMESPACE file export(a, b, c, ..., z) The problems with this are: It's quite tedious to type all of the constant names The

R package: underscores added to RcppExports.R when building

纵然是瞬间 提交于 2019-12-10 10:32:57
问题 I work from different computers on the same R package with Rstudio, but for some reason, whenever I build the package, some of the computers will modify the RcppExports.R and RcppExports.cpp files by adding underscore in front of some functions. For example, this can be found when looking at the dif between the files before and after compiling the package (first line is before, second is after): .Call('PkgName_FunctionName', PACKAGE = 'PkgName', arguments) .Call('_PkgName_FunctionName',

How to use S3 methods from another package which uses export rather than S3method in its namespace without using Depends or library()

风流意气都作罢 提交于 2019-12-10 02:03:04
问题 I'm working on an R package at present and trying to follow the best practice guidelines provided by Hadley Wickham at http://r-pkgs.had.co.nz. As part of this, I'm aiming to have all of the package dependencies within the Imports section of the DESCRIPTION file rather than the Depends since I agree with the philosophy of not unnecessarily altering the global environment (something that many CRAN and Bioconductor packages don't seem to follow). I want to use functions within the Bioconductor

Building R packages with Packrat and AppVeyor

China☆狼群 提交于 2019-12-09 18:27:37
问题 Can someone point me towards a working example where packrat is used with AppVeyor to build an R package? Searching through Google and GitHub, I can't find any packrat-enable package that uses AppVeyor. Does the appveyor.yml file need to change? Are there some settings I need to add through the AppVeyor website? I have a very minimal package ( testthat is the only dependency) that broke AppVeyor builds. Here is the code frozen for that commit. Here is the AppVeyor log. (If this SO question

Renaming and Hiding an Exported Rcpp function in an R Package

前提是你 提交于 2019-12-09 17:37:05
问题 Writing an R package, I have a R function that calls a specific Rcpp function. The Rcpp function just serves as a helper function and I do not want to creat a .Rd file for it. My solution so far is to export both functions in the Namespace file which causes the warning to create an .Rd file for the Rcpp function as soon as I run the check command. If I remove the helper function in the Namespace file, I get rid of this warning causing now the problem that the R function is not able to find it