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).
Related
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
I have been getting this error for the first time for commands that used to run well before:
# conversion from char to numeric:
as.numeric(df$col) -> df$col
Error: (converted from warning) NAs introduced by coercion
# running metafor
rma(yi, vi, data=r1s2)
Error: (converted from warning) Studies with NAs omitted from model fitting.
The issue must be with the R environment as these commands are running perfectly on a different computer. The only wrong I can think of is installing a package from GitHub or updating R a few hours ago. The only relevant answer I've found so far is also not working:
Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS="true")
This seems to be a warning level issue. If the warning level is 2, warnings become errors. From the documentation, my emphasis.
warn:
integer value to set the handling of warning messages. If warn is negative all warnings are ignored. If warn is zero (the default) warnings are stored until the top–level function returns. If 10 or fewer warnings were signalled they will be printed otherwise a message saying how many were signalled. An object called last.warning is created and can be printed through the function warnings. If warn is one, warnings are printed as they occur. If warn is two (or larger, coercible to integer), all warnings are turned into errors.
old_ops <- options(warn = 2)
warning("this is a warning")
#> Error in eval(expr, envir, enclos): (converted from warning) this is a warning
x <- "a"
as.numeric(x)
#> Error in eval(expr, envir, enclos): (converted from warning) NAs introduced by coercion
options(old_ops)
Created on 2022-06-25 by the reprex package (v2.0.1)
If you say that
The issue must be with the R environment as these commands are running perfectly on a different computer.
then check if you have a file named .RData in your R startup directory. If you have one, then you probably set the warning level in a previous session and now it is being restored every time you run R. Delete this file and this behavior will go away.
See also this SO post.
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")
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?
I am getting error for the following execution :
library(adegenet)
library(ape)
dat <- haploGen(seq.l=1e4, repro=function(){sample(1:4,1)}, gen.time=1, t.max=3)
plot(dat, main="Simulated data")
#Error in xy.coords(x, y, xlabel, ylabel, log) :
# 'x' is a list, but does not have components 'x' and 'y'
#Calls: plot -> plot -> plot.default -> xy.coords
Same code works in rweb online !!
I think the problem is with the package.
So I tried updating the package and I get the following error.
** preparing package for lazy loading Error : object ‘renderPrint’ is not exported by 'namespace:shiny'
ERROR: lazy loading failed for package ‘adegenet’ * removing ‘~/R/x86_64-pc-linux-gnu-library/2.14/adegenet’
* restoring previous ‘~/R/x86_64-pc-linux-gnu-library/2.14/adegenet’ Warning in install.packages :
installation of package ‘adegenet’ had non-zero exit status
Also I have similar problems with other plots with same packages loaded. This is the code:
dat <- haploGen(seq.l=1e4, repro=function(){sample(1:4,1)}, gen.time=1, t.max=3)
res <- seqTrack(dat, mu=0.0001, haplo.length=1e4)
plot(res, main="seqTrack reconstruction")
This is the plot I get.
docs.google.com/file/d/0BxRqodN_w-mgeG1hRHdLS0pPZHM/edit
Actual plot should look like
docs.google.com/file/d/0BxRqodN_w-mgcDNPZW1TMFBxeEE/edit
This was tested on rweb online too. I have tested on Rstudio as well. It doesn't make any difference.
Version Details =>
Ubuntu 12.04,
adegenet version 1.3.1,
R version 2.4.1
New version of the adegenet package is 1.4.1 and it is not getting installed from the CRAN repository in the first place (updating error is a separate issue in itself as I have mentioned above).