A package that needs compilation cannot be installed with a different name - r

I have a github clone of the glue R package for reasons. The name of this package is changed into glue.1.3.1 in this repository from its DESCRIPTION file for similar reasons. As a control group, I have an identical repository but this one's name is not changed in any way
If I do
devtools::install_github('oganm/glue.1.3.1')
the installation will fail
Error: package or namespace load failed for ‘glue.1.3.1’ in library.dynam(lib, package, package.lib):
shared object ‘glue.so’ not found
Error: loading failed
Execution halted
If I do
devtools::install_github('oganm/glue)
the installation will be successful.
If I do the same thing to most other packages, there are no problems but it seems like the source code of pacakges that need compilation, the change in the package name causes problems. For instance, you can repeat the issue with dplyr here
The question is, what causes this issue? What do I need to do so that I can reliably change names of packages that require compilation?

Related

"package or namespace load failed" error in loading R package from GitHub

I am trying to load a package in RStudio from GitHub but I get an error.
I have also updated all the packages in order to see if this was the problem but I still get the same error. I have a MAC pc (I don't know if this may cause some problems).
The link of the package that I would like to load is:
https://github.com/andrewraim/COMMultReg
and there is written that in order to load it I need to run
library(devtools)
install_github("andrewraim/COMMultReg")
But when I run the second line I get as error:
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘COMMultReg’ in namespaceExport(ns, exports):
undefined exports: d_cmb, d_cmb_sample, d_cmm, d_cmm_sample, gunterize, loglik_score_fim_cmm, normconst_cmb, normconst_cmm, r_cmb
Errore: loading failed
Esecuzione interrotta
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/COMMultReg’
Warning message:
In i.p(...) :
installation of package ‘/var/folders/n0/4lmr1lrj7qqfylmh6s8qx0nr0000gn/T//RtmpldrmHr/file72e1e4469d/COMMultReg_0.1.0.tar.gz’ had non-zero exit status
Can somebody help me telling me what to do?
Thanks!!
The package has no function named d_cmb, but it tries to export that function. That's what the error message says, and it's true.
I think the reason for this error is that the author used Roxygen2 to generate his NAMESPACE file where the exports are declared, but that file is out of sync with the contents of the package.
It's possible this happened because the author forgot to commit a new file containing the new code. In that case, the best solution is to contact the author, and point out the issue.
Alternatively, it may have happened because at one time there was a d_cmb function, but the author removed it, without updating the NAMESPACE file. This one you might be able to fix yourself.
To fix this, you'll need to run Roxygen2 yourself, which is a little more complicated than just installing what's on Github. Here are the steps:
Fork the package to your own Github account if you have one. (This step is optional, but it makes some later steps easier.)
Download the source for the package. In RStudio, the quickest way to do this is to create a new project using Version Control, Git, and give the URL
of your forked copy, or the original URL if you skipped that.
Run Roxygen2 on the package. In RStudio, you do this by choosing "Document" in the "More" menu of the Build tab.
Try to build it. If you're lucky, it will now build properly. If not, fix the next problem.
This is very important: send your changes back to the original author. If you forked the package, this is easy; if not, figure out a way to do it.
this is the maintainer of the COMMultReg package. I didn't know about this thread until now, but it sounds like you were able to get started from the answer by user2554330.
The functions d_cmb, d_cmb_sample, etc are supposed to be exported. I think the problem may have been that, at the time of the question, I did not have src/RcppExports.cpp and R/RcppExports.R checked into Github. This seems to be necessary to use install_github on a package with exported Rcpp functions. Those were checked in around 8 months ago. (Coincidentally not long after this question was posted?)
Please let me know if you still having trouble with the install. Otherwise, enjoy the package!

Why do I get Error when calling library (rdd)

I have installed the rdd package, when calling library(rdd), I get error an message:
Error: package ‘car’ required by ‘AER’ could not be found"
I have used functions from car (like anova) so I know I have it.
I have MAC OS 10.15.1, R 3.6.1 , I reinstalled R and RStudio.
install.packages("rdd")
library(rdd)
Loading required package: AER
Error: package ‘car’ required by ‘AER’ could not be found
Packages may have dependencies (i.e. other packages) and those dependent package may have dependencies of their very own. Appears that rdd requires AER which in turn requires car. So you need all three (and possibly even more). At the very least you need to now install pkg:car.
(I know this may seem a duplicate but I'm not sure the usual duplicate nominees have seen a multi-level dependency situation such as this. )
Suggest you execute both of this lines:
install.packages("AER", dependencies=TRUE) # should pick up car
# maybe also need install.packages("car", dependencies=TRUE)
install.packages("rdd", dependencies=TRUE)
If you get further errors, pay attention to the first error message and use install package recursively until you establish a full set of dependencies and dependencies of dependencies.

"object not found" during package build/install

I'm at a loss to debug building/installing a package. Building a package "MyProjekt" through
> devtools::build("MyProjekt")
works fine, even though
> devtools::document()
Updating MyProjekt documentation
Loading MyProjekt
Error: object 'rank' not found whilst loading namespace 'MyProjekt'
fails.
Attempting to install the built (pure R) package
> install.packages(pkgs="./MyProjekt.tar.gz")
...
Error: package or namespace load failed for 'MyProjekt':
object 'rank' not found whilst loading namespace 'MyProjekt'
Error: loading failed
Execution halted
...
ERROR: loading failed for 'i386', 'x64'
also fails.
Unfortunately the term 'rank' is a common term in my domain and I have hundreds of hits when searching in my files for that term.
How might I start a systematic way to hunt this bug down?
The toolchain mistakenly generates S3method(...) in the NAMESPACE file.
Follow this answer and edit the NAMESPACE file by hand. Replace occurrences of S3method(f) with export(f).
I'm not certain this is repeatable. The generated files appear to be not just written, but also read during a subsequent package build (by devtools? by roxygen2?). Add your comments if this works/does not work for you.

R packages not loading via library()

I have been experiencing the problem of not being able to load package libraries in R. The packages install fine via instal.packages(), but I get the error
Error: package or namespace load failed for ‘adegenet’ in library.dynam(lib, package, package.lib):
shared object ‘httpuv.so’ not found
Error: package ‘adegenet’ could not be loaded
When I attempt to load the package 'adegenet' (and any other packages).
I recall this behaviour started to occur when I used remove.packages() to remove shiny in order to install the development version on GitHub (shiny-Incubator).
I am unsure as to what is going on. Any ideas on how to restore everything? I updated to the most recent R version, but this did not fix things.
It seems that during your uninstallation procedure you managed to remove a component of httpuv and/or Rcpp. This should get things working again:
install.packages(c("Rcpp", "httpuv"))

cannot load rms package

I'm working with R, I have installed the library 'rms' but I have the follow error:
> library(rms)
Error in library.dynam(lib, package, package.lib) :
DLL ‘colorspace’ not found: maybe not installed for this architecture?
Errore: package ‘ggplot2’ could not be loaded
What can I do?
If you install from base R and wish to install a package and all its dependencies, you need to use the argument dependencies = TRUE. From ?install.packages:
"dependencies = TRUE ... this installs all the packages needed to run pkgs, their examples, tests and vignettes (if the package author specified them correctly).
Hence,
install.packages("rms",dependencies = TRUE)
should do the trick.
The answer offered so far (without any upvotes so far) is useful, but incomplete. It is sometimes sufficient to execute install.packages() with dependencies = TRUE, but if the missing package is a dependency of a dependency, then install.package is not "smart" enough to recognize that fact. The ggplot2 package is in the "Depends:" line of the rms package DESCRIPTION file, but colorspace is not. Sometimes the end-user simply needs to read the error message and install the missing dependencies.
In this case, however, it appears that there may have been a version mismatch of packages and R.

Resources