Error trying to download Github package on r - r

I am trying to download the package 'seegSDM' package but keep getting an error despite trying a couple different ways.
I am using Rx64 3.6.2 and have been using the package 'githubinstall' to try and download the package.
library(githubinstall)
gh_install_packages("seegSDM")
When I use this I get the error
"Error: unexpected string constant in:
"suppressPackageStartupMessages(.getRequiredPackages(quietly = TRUE))
tools:::makeLazyLoading("seegSDM", "C:/Users/Laptop'"
Execution halted
ERROR: lazy loading failed for package 'seegSDM'
* removing 'C:/Users/Laptop/Documents/R/win-library/3.6/seegSDM'
Error: Failed to install 'seegSDM' from GitHub:
(converted from warning) installation of package ‘C:/Users/Laptop'~1/AppData/Local/Temp/Rtmpe6YLGi/file26b07cc06130/seegSDM_0.1-9.tar.gz’ had non-zero exit status
In addition: Warning message:
In fread(download_url, sep = "\t", header = FALSE, stringsAsFactors = FALSE, :
Found and resolved improper quoting out-of-sample. First healed line 4848: <<Puriney honfleuR "Evening, honfleuR" by Seurat>>. If the fields are not quoted (e.g. field separator does not appear within any field), try quote="" to avoid this warning.
Any advice? I need to use the function neasrestLand so I can nudge points on a raster to the nearest land.

It think you need to add the organization name (SEEG-Oxford). The package installs fine with
remotes::install_github("SEEG-Oxford/seegSDM"
and I suppose it might also work with
gh_install_packages("SEEG-Oxford/seegSDM")

Related

install.packages() ignoring option to convert warning to error?

I'm trying to find a simple way to make install.packages() throw an error if it fails (rather than just a warning).
What I've tried
Setting options(warn=2) converts warnings into errors. Example:
options(warn=2)
warning()
# Error: (converted from warning)
I expected this would now error:
install.packages('thispackagedoesntexist')
# Warning in install.packages :
# package ‘thispackagedoesntexist’ is not available for this version of R
#
# A version of this package for your version of R might be available elsewhere,
# see the ideas at
# https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
yet it still just gives a warning (no error).
Question
How can install.packages() be made to error (rather than simply warn) on any sort of failure?
Note:
There are a few nice ways of making install.packages() error instead of warning, but I'm scouting for something much more lightweight, preferably without installing other packages, which options() would achieve nicely (if I can get it working).
This is an RStudio "feature".
First I wondered why the warning isn't printed in red. Then I looked at install.packages (in RStudio) and saw this:
> install.packages
function (...)
.rs.callAs(name, hook, original, ...)
<environment: 0x1408432c8>
> getAnywhere(.rs.callAs)
A single object matching ‘.rs.callAs’ was found
It was found in the following places
tools:rstudio
with value
function (name, f, ...)
{
withCallingHandlers(tryCatch(f(...), error = function(e) {
cat("Error in ", name, " : ", e$message, "\n", sep = "")
}), warning = function(w) {
if (getOption("warn") >= 0)
cat("Warning in ", name, " :\n ", w$message, "\n",
sep = "")
invokeRestart("muffleWarning")
})
}
<environment: 0x1181b4928>
See how warnings are handled and how the printed "warning" isn't actually a warning but cat output?
If I run your code in Rgui, I see this:
> options(warn=2)
> install.packages('thispackagedoesntexist')
Error: (converted from warning) package ‘thispackagedoesntexist’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
So, I suggest you go to the RStudio developers and complain that they use cat to misleadingly print "errors" and "warnings".
You can avoid RStudio's masking of install.packages the usual way:
> options(warn=2)
> utils::install.packages('thispackagedoesntexist')
Error: (converted from warning) package ‘thispackagedoesntexist’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

CRAN checks errors on roxygen #examples: base::assign and missing reshape2

I am trying to push the following package to CRAN, but I keep getting an error on the check.
Error:
✓ checking R/sysdata.rda ...
WARNING
‘qpdf’ is needed for checks on size reduction of PDFs
✓ checking installed files from ‘inst/doc’ ...
✓ checking files in ‘vignettes’ ...
E checking examples (3s)
Running examples in ‘oRus-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: analyseStories
> ### Title: Analysing Stories
> ### Aliases: analyseStories
>
> ### ** Examples
>
> # Transform the stories
> fileUrl <- example_stories()
> stories <- analyseStories(fileUrl, 7)
Joining, by = "word"
Joining, by = "word"
Error in loadNamespace(name) : there is no package called ‘reshape2’
Calls: analyseStories ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
Current problems:
The example is in orus::analyseStores(...) function.
The example actually runs and works on the pkgdown website.
The error appears only when doing devtools::check
I have tried multiple things:
This answer base::assign(".ptime", proc.time(), pos = "CheckExEnv") ERROR when using devtools::check suggested using dontrun{...}. It passes CRAN's check, but it was bounced by a person after a couple of days.
This answer R package fails devtools::check, because "could not find function" even though the function is imported in NAMESPACE suggested doing require on the missing library. I did require(reshape2) but the check still does not pass.
This answer "Could not find function" in Roxygen examples during CMD check suggests that I need to make all my functions public (exported). I don't want to do that. I tried doing orus:::some_function(...) to call to the non-exported functions inside analyseStores but it doesn't work either.
According to this one: R package build failed when checking examples the data is working and the function has the #export tag. Also, namespace is properly updated.
I have run out of options. Any idea of what is happening?
As #stefan suggested in the comments, I had to add reshape2 into the Suggested packages in the description file. I added using:
usethis::usepackage("reshape2", "Suggests")
Followed by regenerating the docs:
devtools:document()
Package is on its way to CRAN!

R: Encoding issues when installing package from Github

I am trying to install the dcStockR package from Github, which is an htmlwidgets wrapper around the dc.js dimensional visualization library: devtools::install_github("yutannihilation/dcStockR").
I get the following encoding error:
* installing *source* package 'dcStockR' ...
** R
Error in parse(outFile) :
C:/Users/tirthankarc/AppData/Local/Temp/Rtmpcz8pHX/devtools153839438c/yutannihilation-dcStockR-c6091c8/R/dc.R:11:59: unexpected input
10: #' #export
11: dc <- function(data, chartRecipe = c("yearlyBubbleChart",ã€
^
ERROR: unable to collate and parse R files for package 'dcStockR'
* removing 'C:/Users/tirthankarc/Documents/R/R-3.2.5/library/dcStockR'
Error: Command failed (1)
The offending lines of the file in question can be viewed here: https://github.com/yutannihilation/dcStockR/blob/master/R/dc.R#L11.
Two questions:
Is this error reproducible for others?
If so, is there a way to fix this by passing an explicit encoding option to install.packages? If not, what other options are available to fix this issue?

How to update and recompile nlme source code in R

I am attempting to update the ‘nlme’ package so that I can use great circular distances for the correlation in the gls command. I'm attempting to edit the source code with the changes specified here.
I am unsure about how to proceed in re-compiling the package with the updated source code. I am able to edit the source within the .tar.gz, but when I try to install the package from my local folder, I receive:
Installing package into ‘C:/Users/HSRG1/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
* installing *source* package 'nlme' ...
files 'R/corStruct.R', 'R/gls.R', 'R/lme.R' have the wrong MD5 checksums
** libs
*** arch - i386
ERROR: compilation failed for package 'nlme'
* removing 'C:/Users/HSRG1/Documents/R/win-library/3.0/nlme'
Warning messages:
1: running command '"C:/PROGRA~1/R/R-30~1.0/bin/x64/R" CMD INSTALL -l "C:\Users\HSRG1\Documents\R\win-library\3.0" "nlme_3.1-111.tar.gz"' had status 1
2: In install.packages("nlme_3.1-111.tar.gz", repos = NULL, type = "source") :
installation of package ‘nlme_3.1-111.tar.gz’ had non-zero exit status
The functions R/corStruct.R', 'R/gls.R', 'R/lme.R are those which I am trying to edit. I do not know what this error means, particularly the bit about having incorrect checksums (I suspect the other errors follow). I found the following link: http://r.789695.n4.nabble.com/R-3-0-0-wrong-MD5-checksums-for-Windows-td4663348.html which discusses a different linebreak command which is implemented when compiling from Windows, but I do not know how this is relevant (or soluble) as the source has no linebreak declarations.. There is clearly something I'm missing.
I am using a Windows 64 bit computer - please let me know if there is any other information I need to provide.
UPDATE: As suggested I have tried to implement the corRGaus correlation in the ramps package. When I try to use the corRGaus correlation I get the following error:
y = runif(50, 1, 40)
x = runif(50, 1,20)
LC= c(rep(1,25), rep(2,25))
lat = runif(50,-90,90)
long = runif(50,180,180)
fit <- lme(y ~ x,random = ~x|LC, cor = corRGaus(form = ~lat+long))
Error in `coef<-.corSpatial`(`*tmp*`, value = value[parMap[, i]]) :
NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning messages:
1: In nlminb(c(coef(lmeSt)), function(lmePars) -logLik(lmeSt, lmePars), :
NA/NaN function evaluation
2: In nlminb(c(coef(lmeSt)), function(lmePars) -logLik(lmeSt, lmePars), :
NA/NaN function evaluation
3: In nlminb(c(coef(lmeSt)), function(lmePars) -logLik(lmeSt, lmePars), :
NA/NaN function evaluation
4: In nlminb(c(coef(lmeSt)), function(lmePars) -logLik(lmeSt, lmePars), :
I am not sure what this error means, nor how to remedy it.
As a side note, after installing ramps, I am no longer able to use the corGaus correlation until restarting R (even if I detach the ramps package).

dependent packages not loading in R on Debian

I'm having trouble loading the sde package on a clean Debian install running R 2.11.1. I've seen this behavior with some other packages, however, so I don't think it's specific to only this one package. Here's an example of the conundrum:
>install.packages("sde", lib.loc=libPath)
... installs sde, and the packages it's dependent on: zoo, fda
> library(sde, lib=libPath)
Loading required package: fda
Error: package 'fda' could not be loaded
In addition: Warning message:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :
there is no package called 'fda'
ok, that's odd. I saw fda being installed. So I manually load the dependencies:
> library(zoo, lib=libPath)
> library(fda, lib=libPath)
Loading required package: splines
ok, that worked. Now let's try sde:
> library(sde, lib=libPath)
To check the errata corrige of the book, type vignette("sde.errata")
WTF? it loaded fine?!?
So why can I manually load the packages but R is not picking them up automagically?
Adding to my confusion, I discovered during debugging that if I don't use the lib=libPath then everything works just fine. So it looks like the use of a custom path for packages is screwing this all up... but why?
You confirmed my suspicions in the comments. You need to do one of two things:
.libPaths(libPath)
or
library(sde, lib=c(libPath,.libPaths()))
I prefer the first method because the second requires you do that for all calls to library.

Resources