Error executing functions from own R package - r

I created my own package with the RStudio build tools and building/loading the package via the build tools works fine. My functions run as desired and the documentation works fine as well.
Writing the package as a source file works fine, too, as well as installing the package from source. Though, when I execute functions after installing the package from source I get an "R code execution error" as well as the error message
Error in fetch(key) : cannot allocate memory block of size 2.7 Gb
The size of the memory block in the error message varies every time.
So the problem is that I can't run any functions after installing the package from source. I need to be able to share the package as a source file though.
Does anyone have experience with this kind of problem? Is it related to writing the package as a source file? I could not find anything so far.
Additional info: When I run the "check package" command, everything works fine except for one error checking the given examples. The examples should not be an issue though, right?

Related

Vignette fails to be built by pkgdown

I have a R package that I am trying to setup pkgdown for. I'm following the instructions here, and am running build_site() to generate the docs directory. When running this command, I get the error
Quitting from lines 28-29 (Data-Model.Rmd)
Error : package or namespace load failed for 'dm':
.onLoad failed in loadNamespace() for 'dm', details:
call: register_pkgdown_methods()
error: rlang::is_installed(c("DiagrammeR", "DiagrammeRsvg")) is not TRUE
Showing that the build is failing when trying to render one of the vignettes. However, if I just try to knit this vignette in a fresh interactive session, it knits fine.
I have tried including DiagrammeR and DiagrammeRsvg in Depends, Imports, or Suggests, and it still fails with the same error.
Any idea what I can do to fix this? The vignette is located on my github here. I understand this is not the ideal way to share an example, but it can repro'd by cloning the repo and running pkgdown::build_site()
The error is fairly informative; it tells you that
rlang::is_installed(c("DiagrammeR", "DiagrammeRsvg"))
is not TRUE. I suspect if you run that line it will in fact return FALSE. I installed DiagrammeRsvg and the vignette built successfully.
I am not entirely sure why building the vignette with pkgdown requires SVG export of your diagrams, but knitting them doesn't. Hopefully that solves the issue, though.

Build fails automatic checks on CRAN but not on any local checks

I am trying to submit a new package to CRAN. After submitting, I got a response that it been rejected beacuse it did not pass the automated checks.
Specifically, the error message was as follows for the Windows build.
* checking package dependencies ... ERROR
Package required but not available: 'readr'
See the log for Windows here. It passed all checks for the Debian build fine (side note, I am fixing the NOTES relating to URL's).
The package passes all check on my local machine (Mac OS) as well as on travis-ci and using rhub/devtools to test on Windows. Specifically, I can run the following all without errors.
devtools::check()
devtools::check_win_develop()
rhub::check_for_cran()
Regarding readr which seems to be the cause of the issue, it is in the DESCRIPTION file as an Import and seems to be referenced correctly in the various functions. And again, all the above checks pass fine.
Is there some other way to test for CRAN that I'm missing here? I'm hesitant to resubmit without any changes but am not really sure what to change as I can't work out what is going wrong.
For reference, the package is on github.

R package not found, but present in correct library

I have a problem with the R package "gridExtra". Everything is ok, when I go into R and load it, but when I execute a python script, which among others also loads this package, everything stops. I don't understand it, since I checked the library and the right library is selected.
It's a little complicated, because the script is from someone else. It can be accessed from here: https://github.com/guigolab/ggsashimi/blob/master/sashimi-plot.py. The package is loaded at row 430. Loading the previous packages was no problem, after installing them into the custom library. During the python script, a custom R script is generated and executed. Within this R script, the package is loaded usign the function library(gridExtra).
The error message is:
Error in library(gridExtra) : there is no package called ‘gridExtra’
Execution halted
I checked, if the generated R script really accesses the right library and it does, so there is no problem with the library selection.

Why does building an R package stop my code from working?

It seams that upon installing my custom R package code stops to work? Why?
In detail, I have a tiny R package goEnrichment (click to see the Github repo). The R package includes just just two functions and some binary data.
Also there are two test R-scripts that I run after installing the R package with R CMD INSTALL goEnrichment. One test script fails while the other works.
The only difference between the two scripts is that in the working version I require the necessary libraries and source the functions file manually, while in the other failing script I require my goEnrichment library directly.
Note, that both scripts are started directly from their directory goEnrichment/exec.
Start the working test with cd goEnrichment/exec && Rscript testGoEnrichment_works.R. Excerpt:
# This is the WORKING version
require(GOstats)
require(GSEABase)
require(RMySQL)
source( "../R/goEnrichment.R" )
Start the failing test script with cd goEnrichment/exec && Rscript testGoEnrichment_fail.R. Excerpt:
# This version FAILS
require(goEnrichment)
The error I get is somewhat uninformative to me:
'dimnames' applied to non-array.
The built R package fails on two platforms, that is on Debian Wheezy 64 with R 3.0.2 and on Mac OS X Yosemite with R 3.1.1.
I really have no clue why this happens. I checked for file format and unexpected characters using Vim. The cause does not seem to be the DESCRIPTION file either, because all libraries, goEnrichment depends on, are imported.
Does any one have a clue what causes this very weird error? Help will be much appreciated.
After much testing I found the source of the problem.
For some reason when requiring my package with
require(goEnrichment)
the generic function
summary.GOHyperGResult
is not loaded, as it should be. The method however is available when the packages, goEnrichment depends upon, are required manually. As to why this is, I had no time to investigate. I believe the here reported error is related to this bug.
Thanks to Tyler for your efforts, very much!

Error in loadNamespace(name) : there is no package called 'Rcpp'

I am trying to embed RInside to my application on win7 64-bit system but when I initialize an RInside:
Rin = new RInside(argc, argv);
the following message appears:
Error in loadNamespace(name) : there is no package called 'Rcpp'
This error only occurs with Windows.
I think you get that issue when your .libPaths() differ--in other words run the .libPaths() function to see the paths stored by R for its use. Then check where RInside is installed, and make sure Rcpp is installed there too. It is a setup issue.
In other words, it should work if you have Rcpp and RInside installed where the basic R libraries are. Otherwise you have to tell the (embedded) R session about the other location (and before it starts).
There are more Windows users on the list, so you could try asking on rcpp-devel.
First get your default library locations by command ".Library" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step1.
Now you are ready to install packages which have dependencies on Rcpp.
Dirk is right in this case, BUT if the .libPaths() does not work, then please also check if you have the latest packages.
I am posting this as an ancillary answer backup which I ran into with the shiny package backend switch of their code needing Rcpp!
In this case of getting the "no package" error message, I fixed it by:
Selecting devtools package and then using this line below. (if you don't have devtools then get it with install.packages("devtools")
devtools::install_github("rstudio/shiny")
The development version of the package handled this better, and added the package as a dependency.
Mods - I realize this is an answer to an old question, but I might help others not wasting an hour like I just did.
You might find it easy if the answers are for both R studio users and non R studio users.
R Studio users
First get your default library locations by command ".Library" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.
Non R studio Users
First get your default library locations by command ".libPath" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.
I was also getting this error while trying to run the 'ggplot' function from the ggplot2 package. After trying the suggestions posted here and elsewhere (checking file paths, restarting R, clearing out my environment, etc.) and encountering several other cryptic error messages, it turned out that I needed to download the latest version of base R for Windows (v3.4.1) and update my version of R-Studio to the latest version also (v1.0.153).
After doing this my 'ggplot' function was working again and I was able to render my figure from R Studio without any further issues.
I was also getting this message when trying to use ggplot. I first updating both my R for Windows to 3.4.3. Then updating R studio to version 1.1.423; then, updating all of the packages and being sure to access the R version 3.4.3 from R studio, I still got the message. None of these things fixed the error. I was ready to give up until I noticed that I was calling library(ggplot) and had ggplot::ggplot in my code. THIS WAS THE PROBLEM. I changed it to library(ggplot2) and the instance to ggplot2::ggplot(...). THIS FIXEd the problems.
I was facing a similar issue, and I simply installed the said package. It's working perfectly for me.

Resources