loading Rcpp through JGR Console - r

I have created a package that depends on Rcpp and RcppArmadillo. My package operates smoothly without a problem on the R console. However, when I try to loaded it from JGR console it reports the following error
Error: package 'Rcpp' 0.9.9 is loaded, but >= 0.9.10 is required by 'RcppArmadillo'
Actually, I have updated Rcpp to version 0.9.10 on my machine. In the R console you can see that
sessionInfo()
attached base packages:
[1] compiler stats graphics grDevices utils datasets methods base
other attached packages:
[1] prophecy_2.1 XLConnect_0.1-9 XLConnectJars_0.1-4 rJava_0.9-3 RcppArmadillo_0.2.36 Rcpp_0.9.10
I appreciate the help.

This has nothing to do with Rcpp and is all about your R patch:
Print the result of .libPaths()
Look at the result of library()
Do that both on the console and with JGR. You probably have different outcomes.
Delete the old Rcpp 0.9.9 in the path added by JGR.

Related

circular dependency error in R package check, yet no circular refs in Depends

I am getting a circular dependency error for my R package when running CHECK:
checking package dependencies ... ERROR
There is circular dependency in the installation order:
One or more packages in
then a long list of packages.
However, my Depends category in DESCRIPTION is very minimal:
Depends: methods, R (>= 3.5.0), magrittr
And all other referenced packages are in either Imports or Suggests. One package I have in Imports also lists my package in their Imports, but I did not think that would lead to a dependency issue. I don't think any of the other packages I have in DESCRIPTION list mine in theirs.
I've searched quite a bit online but found no relevant solutions. Any ideas? Thanks in advance for the advice.
Session info:
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5 tinytex_0.31 xfun_0.28
Depends and imports both require a dependency. The main difference is that imports doesn't add items to the user's search path. See here or here. You can't list a package under your "imports" that lists you under their "imports" -- that part is the same as "depends." Packages use functions from packages all the time, but the sharing is just one-way.
One possible work-around is copying the function (with permission from the other package author) into your own package.
Another option that I've seen used by other packages is to move shared logic to a separate helper package and then both packages can Import that helper package.
Finally, if it's a function you don't really need you can move it to suggests and then check if that package is installed only when you need the function and can throw an error if not.

Rcpp Rcpp.package.skeleton("mypackage") "rcpp_hello_world" not available for .Call() for package "mypackage"

I've managed to get the Rcpp.package.skeleton to INSTALL in Windows by the following commands at the R prompt -
Rcpp.package.skeleton("mypackage")
system("R CMD build mypackage")
system("R CMD INSTALL mypackage")
library(mypackage)
This creates the mypackage.dll. However when I do the following commands -
rcpp_hello_world <- function(){ .Call( "rcpp_hello_world", PACKAGE = "mypackage")}
rcpp_hello_world()
I get the following error:
Error in .Call("rcpp_hello_world", PACKAGE = "mypackage") :
"rcpp_hello_world" not available for .Call() for package "mypackage"
I run sessionInfo() and I get the following:
attached base packages:
[1] tools stats graphics grDevices utils datasets methods base
other attached packages:
[1] mypackage_1.0 inline_0.3.13 Rcpp_0.11.1
Stating that my new mypackage is there.
Are there any further checks I can do to see what is happening? Any ideas?
FWIW, I just got a similar error while retrofitting an existing R-only package with Rcpp, and the problem was a missing useDynLib(mypackage) in NAMESPACE.
The package is tested extensively before every release, including on the Windows-using Win-builder. The regression tests even include building a package this way via a call to package.skeleton().
It is also rebuilt by CRAN post-release. Many people use it.
For all of those people, tests are appropriate and when long long cannot be used, it is #define-d away.
Now, you insist on building in a non-standard way: no source I know of recommends calling R CMD INSTALL via system(). I suspect you simply have a $PATH mishap and find another wrong g++ version.
I would suggest to do what the documentation suggests and run
R CMD INSTALL mypackage*tar.gz
in a cmd.exe prompt.
If the package NAMESPACE file contains the line
useDynLib(mypackage, .registration = TRUE)
(perhaps via a roxygen line #' #useDynLib, .registration = TRUE), then it is necessary to remove PACKAGE = "mypackage" from .C / .Call function calls:
i.e.
.Call( "rcpp_hello_world", PACKAGE = "mypackage")
becomes .Call("rccp_hello_world").

install.packages("methods") failed for R 3.0.1

I try to install R package "methods" over R 3.0.1:
> install.packages("methods")
> Warning message:
package ‘methods’ is not available (for R version 3.0.1)
Is there any way to install 'methods' over R 3.0.1 or should I switch to R 3.0.0?
Thank you
methods is part of base R, you don't have to install it with install.packages, as it is already bundled with your R 3.0.1 installation.
You will see that loading the package will not provide any error :
library(methods)
But you don't even have to do that, as it is already loaded by default in your R session.
methods is a base package, along with the following packages
base
compiler
datasets
graphics
grDevices
grid
methods
parallel
splines
stats
stats4
tcltk
None of these packages are on CRAN, they only exist as part of base R.
See also the R FAQ Section 5.1.1.

Can't use a installed package in R

I have installed a package in R (ggmap), but when I try to use it R gives an error:
> library()
... (all the rest)
gdata Various R programming tools for data
manipulation
ggmap A package for spatial visualization with Google
Maps and OpenStreetMap
ggplot2 An implementation of the Grammar of Graphics
...
> library("ggmap")
Error in FUN(structure(c("write_png", "read_png"), .Names = c("write_png", :
no such symbol write_png in package/Library/Frameworks/R.framework/Versions/3.0/Resources/library/png/libs/png.so
Error: package or namespace load failed for 'ggmap'
Any suggestion? Thanks!
PD:
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
EDIT, solution:
Delete ~/Applications/R.app and Library/Frameworks/R.framework and install R again.
Could in be that you have another R installation for an earlier version 3.0 vs the 3.0.1 showing in your sessionInfo()?
Error in FUN(structure(c("write_png", "read_png"), .Names =
c("write_png", : no such symbol write_png in
package/Library/Frameworks/R.framework/Versions/3.0/Resources/library/png/libs/png.so
Error: package or namespace load failed for 'ggmap'
Go to the RStudio-->Options-->Global-->'General'-->R Version
Change the R Version to the latest one which you want to use.

check.Renviron being ignored (OSX + R 2.15)

The semester has ended and I'm now bringing some packages up to R 2.15 (I did not want to change them while students were using them). So I'm doing my usual thing, which worked under R 2.14. As far as I can see, the documentation has not changed with respect to any of this, but I may have missed it.
I have edited my package ChemoSpec but when I go to check it, R gives an error about packages required but not available, then lists them. These packages are available, they are in a local directory which is pointed a-:
.libPaths()
[1] "/Users/bryanhanson/R_pkgs"
[2] "/Library/Frameworks/R.framework/Versions/2.15/Resources/library"
The allegedly missing packages are in fact in /Users/bryanhanson/R_pkgs.
I am aware my .Rprofile is skipped by the checking process, so the .libPaths are not being set by .Rprofile Instead, I have a check.Renviron file which is located in /Users/bryanhanson/.R and contains the following lines:
# Bryan's check.Renviron for customizing check environment
# resides in /Users/bryanhanson/.R
R_LIBS = /Users/bryanhanson/R_pkgs
I have tried to check with the following commands in the terminal
R --as-cran CMD check ChemoSpec
R --vanilla CMD check ChemoSpec
The response to each of these is slightly different, but both fail because of not finding the dependencies, because, apparently, R is not looking in /Users/bryanhanson/R_pkgs even though I think I have told it do so.
Any suggestions? It must be something simple.
Here is the sessionInfo():
sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] sos_1.3-1 brew_1.0-6

Resources