r-package

Test interaction with users in R package

一笑奈何 提交于 2019-12-05 02:28:18
问题 I am developing an R package and one of the function implements interaction with users through standard input via readline . I now wonder how to test the behavior of this function, preferably with testthat library. It seems test_that function assumes the answer is "" for user-input. I wish I could test the behavior conditional of various answers users may type in. Below is a small example code. In the actual development, the marryme function is defined in a separate file and exported to the

R package dependencies

一曲冷凌霜 提交于 2019-12-05 00:42:00
i'm trying to build a R package, but it seems that there are some problems with the package dependencies. If I run the code in R, I need the packages "rgdal" and "rgeos", so for creatng the package out of it, I: Added the line "import(rgdal, rgeos)" to the NAMESPACE file Added the line "Depends: rgeos, rgdal" to the DESCRIPTION file When I run R CMD check (after build) I got an error which says: * checking package dependencies ... ERROR Benötigte, aber nicht verfügbare Pakete: 'rgeos' 'rgdal' See the information on DESCRIPTION files in the chapter 'Creating R packages' of the 'Writing R

When does a package need to use ::: for its own objects

不打扰是莪最后的温柔 提交于 2019-12-05 00:37:54
Consider this R package with two functions, one exported and the other internal hello.R #' @export hello <- function() { internalFunctions:::hello_internal() } hello_internal.R hello_internal <- function(x){ print("hello world") } NAMESPACE # Generated by roxygen2 (4.1.1): do not edit by hand export(hello) When this is checked ( devtools::check() ) it returns the NOTE There are ::: calls to the package's namespace in its code. A package almost never needs to use ::: for its own objects: ‘hello_internal’ Question Given the NOTE says almost never , under what circumstances will a package need to

How to create CRAN ready R package that have external dependencies (libxml2)

旧街凉风 提交于 2019-12-04 19:12:19
I have created an R package that I would like to submit to CRAN. It contains code that needs to be compiled (plain C) and this code depends on the libxml2 library. My current solution is to let Linux and Mac users install the libxml2-dev package, which lets them compile and install the R source package. For Windows I have created a special binary R-package that contains the needed binary dependencies. When reading the CRAN guidelines I see that only source packages may be uploaded and that they may not contain any binary files. My questions are then: Is it ok for Mac/Linux to have the user

accessing sysdata.rda within package functions

拥有回忆 提交于 2019-12-04 16:20:03
问题 I thought that putting an internal dataset for a package into R/sysdata.rda would make the data accessible to my functions. But I can't seem to figure out how to actually access this dataframe. None of the documentation actually says how to access the data, but my guess was that I could simply refer to the dataframe by name. However, this does not seem to work. I used devtools::use_data() with internal = TRUE and sysdata.rda was created. Lazy-loading is set to TRUE. To test it, I manually

Understanding `Makevars` for linking to external C library in R package

僤鯓⒐⒋嵵緔 提交于 2019-12-04 12:15:25
I am working on a package which includes C code from third-party library (SUNDIALS). The package compiles and works (i.e., is able to solve a test ODE) with the following Makevars file performing static linking CXX=clang++ PKG_CPPFLAGS = -I../inst/include PKG_LDFLAGS = /usr/local/lib PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(PKG_LDFLAGS)/libsundials_cvode.a $(PKG_LDFLAGS)/libsundials_nvecserial.a However, a slightly modified version (based on the example in R-Exts, i.e. - PKG_LIBS = -L$(XML_DIR)/lib -lxml2 ) of Makevars (below) fails CXX=clang++ PKG_CPPFLAGS = -I../inst/include PKG

Building R packages with Packrat and AppVeyor

≯℡__Kan透↙ 提交于 2019-12-04 08:46:48
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 sounds familiar, I'm about to ask a similar question for Travis-CI .) Ben Yes, the solution here is

checking CRAN incoming feasibility … NOTE Maintainer

丶灬走出姿态 提交于 2019-12-03 09:19:29
When I run R CMD check --as-cran on my package, the one note I still get is: checking CRAN incoming feasibility ... NOTE Maintainer:[my name] <my email> I can't seem to find a good explanation of this note, although I haven't read anything that tells my I should be concerned about it. As anyone else run into this? Is there anything I can do that will clear the note? According to CRAN Maintainer Uwe Ligges, This is just a note that reminds CRAN maintainers to check that the submission comes actually from his maintainer and not anybody else. Thus, it is safe to ignore such a message. These

Package Relative Paths in R

末鹿安然 提交于 2019-12-03 05:57:33
I've written a few functions for a package that use relative paths like: "./data/foobar.rds" Here's an example function: foo <- function(x) { x <- readRDS("./data/bar.rds") return(x) } Now, if I were to be working in the development path of the package, this works as I expect. But when I load the package, this path uses the current working directory rather than the relative path of the package. How does one set it up such that the path for functions within a package maintain their within the package relative paths? As Andrie notes, you can use system.file , which "finds the full file names of

R rgl Package crashes Rstudio

ぃ、小莉子 提交于 2019-12-02 03:17:09
问题 Does anyone use R rgl package (version 0.95.1201) in Rstudio (Version 0.99.489)? Every time I call library(rgl) , Rstudio crashes. Update I updated rgl by installing version 0.95.1367 from source. Rstudio still crashes. But when I run it in R GUI or R in terminal, there is no problem. Recently I updated my XQuartz to 2.7.9_beta1. I am not sure if this could be the reason. My system is: Mac OSX Yosemite 10.10.5 回答1: I had the exact same problem. You have to set the environment variable: LIBGL