Geomorph not functioning after update - r

I recently updated my MacBook air (2017) to the Mojave OS and proceeded to update my version of R and Rstudio. Unfortunately, ever since the 'plotTangentSpace' command no longer functions appropriately even when attempting to run the example 'plethodon' code from the Geomorph vingette, I always receive the following error in the output (bolded below):
data(plethodon)
Y.gpa<-gpagen(plethodon$land) #GPA-alignment
|====================================================================================| 100%
gp <- interaction(plethodon$species, plethodon$site)
plotTangentSpace(Y.gpa$coords, groups = gp)
Error in plotTangentSpace(Y.gpa$coords, groups = gp) :
unused arguments (Y.gpa$coords, groups = gp)
I have tried uninstalling and reinstalling R for a MacOS many times including versions 4.0.2, 3.6.3, 3.6.1, and 3.2.1. I have also uninstalled and reinstalled XQuartz several times.
If anyone has encountered a similar issue or has any other ideas I can try I would really appreciate the help. Thank you!

If you execute:
?plotTangentSpace
You should see that this is a deprecated function. That means you should not be using it. It says:
Notes for geomorph 3.3.0 and subsequent versions
I suspect you have not updated your copy of the vignette. There are instructions on the help page for an alternate approach. The example in the help page for the suggested function is:
data(plethspecies)
Y.gpa <- gpagen(plethspecies$land) #GPA-alignment
### Traditional PCA
PCA <- gm.prcomp(Y.gpa$coords)
summary(PCA)
plot(PCA, main = "PCA")
For the plethodon data they suggest:
PCA.w.phylo <- gm.prcomp(Y.gpa$coords, phy = plethspecies$phy)
summary(PCA.w.phylo)
plot(PCA.w.phylo, phylo = TRUE, main = "PCA.w.phylo")
So start a new session (to unload the currently loaded geomorph namespace, and execute this at the r session command line:
install.packages("geomorph")
You should be getting version 3.3.1 of the geomorph package.

I think I found the problem! In my case, the error was due to a old version of the package RRPP, which is required by Geomorph. After updating it, Geomorph is working perfectly! Hope this can be useful for you too.

I came across the same error but after updating the RRPP and rgl packages required for geomorph, the gm.prcomp() function worked for me. I hope this helps if you haven't figured it out already.

Related

pathtrackR - S4 vector needs to be a double

I am using R for the first time as part of my dissertation and have been given code from my supervisor who got it from someone else (code attached below with comments from my supervisor). When I try to run it, I get this error and I am unsure how to resolve it.
Error at line 50:
ww<-manualPath("C:/Users/Erin/Document/4th year university/Honours Project/Data files/AOTEA/Jan/508_C5_JAN25_0922",1000,1000,fps=4)
Click once on the top left corner of your arena, followed by clicking once on the bottom right corner of your arena, to define the opposing corners of the entire arena...
Error in as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
My supervisor thinks that the issue is that when the pathtrackR package was created it relied on other packages which have subsequently been updated while it hasn't. These updated packages won't, in turn, function on an older version of R where pathtrackR will work, and so the two fall down.
We know that the error is because the S4 vector needs to be a double, but I don't have enough coding experience to examine the pathtrackR package myself to determine why this is the case.
I was wondering if there is a workaround without reworking the code, or if anyone has any other help or advice on what I could try.
Any help is much appreciated.
######### REQUIRES AN OLDER VERSION OF R TO EFFECTIVELY RUN. I AM USING 3.6 FOR THIS
install.packages("devtools")
library(devtools)
find_rtools() #should return TRUE if an appropriate level of package is present (although F doesn't seem to affect functionality of package?)
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("EBImage")
library(EBImage)
#ONLY NEED TO REVISIT GITHUB IF IT HASN'T BEEN UPDATED IN A WHILE
install_github("aharmer/pathtrackr", build_vignettes = TRUE)
install.packages("digest", dependencies=TRUE) #seems to resolve issues about not instaling newest versions?
library(pathtrackr)
#####BIG ISSUE SEEMS TO BE ANY PROBLEM REQUIRES CLOSING R AND REOPENING......
#######################################################################
#######################################################################
#MANUAL TRACKING
#seems to be resolved on mac following additional install of XQuartz & Xcoe (had to find an old version from
#eg. https://stackoverflow.com/questions/7047735/where-can-i-download-old-versions-of-xcode Need version 9.2 for
#macOS Sierra 10.12.6)
#see also here https://www.r-bloggers.com/installing-r-on-os-x/
library(devtools)
find_rtools() #should return TRUE if an appropriate level of package is present
library(pathtrackr)
################### NB OPENING MORE THAN 2 VIDEOS WITHOUT CLOSING & RESTARTING R LEADS TO
################### SIGNIFICANT SLOWING & EVENTUAL CRASHING OF R
################### PROB A WORKING MEMORY ISSUE?
################### EASIEST 'OPTION'FIX' IS TO CLOSE & REOPEN EACH TIME
rm(list=ls())
library(devtools)
#library(sp)
find_rtools() #should return TRUE if an appropriate level of package is present (DOESN'T SEEM TO MATTER WHETHER TRUE OR FALSE???
library(pathtrackr)
####################################################################################################################################
#ww<-manualPath("/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020mp4vids/FirstTimes/710_C2_MAR6_1028",1000,1000,fps=4)
ww<-manualPath("~/Desktop/2020_Data/SLISCALED/806_C2_JAN09_1023",1000,1000,fps=4)
pdf(file='/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/pdf_images/806_Jan09.pdf')
plotPath(ww) #saving image
dev.off()
plotSummary(ww)
pathSummary(ww)
xx<-as.data.frame(ww$movement)
write.csv(xx, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/MovementData/sli806_Jan09.csv",row.names=F)
zz<-as.data.frame(ww$position)
write.csv(zz, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/PositionData/sli806_Jan09.csv",row.names=F)
####################################################################################################################################
#Second run of same commands. Allows you to realise you forgot to write the csv files without having lost all the work as all files are stored under new names
#pp<-manualPath("/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020mp4vids/FirstTimes/712_A4_MAR6_1045",1000,1000,fps=4)
pp<-manualPath("~/Desktop/2020_Data/SLISCALED/807_C7_JAN10_0910",1000,1000,fps=4)
pdf(file='/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/pdf_images/807_Jan10.pdf')
plotPath(pp)
dev.off()
plotSummary(pp)
pathSummary(pp)
ll<-as.data.frame(pp$movement)
write.csv(ll, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/MovementData/sli807_Jan10.csv",row.names=F)
kk<-as.data.frame(pp$position)
write.csv(kk, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/PositionData/sli807_Jan10.csv",row.names=F)
####################################################################################################################################
#Third run of same commands. Ibid.
#yy<-manualPath("/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020mp4vids/FirstTimes/713_B4_MAR6_1052",1000,1000,fps=4)
yy<-manualPath("~/Desktop/2020_Data/SLISCALED/807_D5_JAN09_0846",1000,1000,fps=4)
pdf(file='/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/pdf_images/807_Jan09.pdf')
plotPath(yy)
dev.off()
uu<-as.data.frame(yy$movement)
write.csv(uu, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/MovementData/sli807_Jan09.csv",row.names=F)
oo<-as.data.frame(yy$position)
write.csv(oo, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/PositionData/sli807_Jan09.csv",row.names=F)
####################################################################################################################################
#Fourth run of same commands. Ibid.
#ee<-manualPath("/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020mp4vids/FirstTimes/709_D2_MAR6_1020",1000,1000,fps=4)
ee<-manualPath("~/Desktop/2020_Data/SLISCALED/801_B8_JAN09_0947",1000,1000,fps=4)
pdf(file='/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/pdf_images/801_Jan09')
plotPath(ee)
dev.off()
rr<-as.data.frame(ee$movement)
write.csv(rr, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/MovementData/sli801_jan09.csv",row.names=F)
dd<-as.data.frame(ee$position)
write.csv(dd, "/Volumes/LaCie/MarieCurieFellowship/2020Fieldwork/2020_Data/SLI/PositionData/sli801_jan09.csv",row.names=F)

RStudio session aborts when I run gRbase::stepwise function (undirected graphs)

I'm doing an R project on RStudio (RStudio 2021.09.1+372 "Ghost Orchid" Release for Windows), (R version 4.1.2).
I'm working on Windows 10 x64.
I want to create an Undirected Graph from a dataset:
library(gRbase)
library(gRim)
library(gRain)
data(BodyFat)
BodyFat <- BodyFat[-c(31,42,48,76,86,96,159,169,175,182,206),]
BodyFat$Age <- sqrt(BodyFat$Age)
BodyFat$Weight <- sqrt(BodyFat$Weight)
names(BodyFat)[names(BodyFat) == 'BodyFat'] <- 'BodyFatPerc'
gRbodyfat <- BodyFat[,2:15]
graph.MyGraph <- cmod(~.^., data = gRbodyfat)
AIC.MyGraph <- gRbase::stepwise(graph.MyGraph)
I'm still exploring RStudio and graphical models, so I run these lines from the console, one by one.
When I run the last line of code, R session aborts and I get the following pop-up message:
I've also tried the following lines of code (I changed the last line):
library(gRbase)
library(gRim)
library(gRain)
data(BodyFat)
BodyFat <- BodyFat[-c(31,42,48,76,86,96,159,169,175,182,206),]
BodyFat$Age <- sqrt(BodyFat$Age)
BodyFat$Weight <- sqrt(BodyFat$Weight)
names(BodyFat)[names(BodyFat) == 'BodyFat'] <- 'BodyFatPerc'
gRbodyfat <- BodyFat[,2:15]
graph.MyGraph <- cmod(~.^., data = gRbodyfat)
AIC.MyGraph <- stepwise(graph.MyGraph)
but I get the same problem. I tried three or four times running those lines of code, R aborted everytime.
My gRbase, gRim, gRain, Rgraphviz and RBGL libraries are in the home folder:
C:/Users/MyUser/Documents/R/win-library/4.1
Any advice?
EDIT:
I've tried uninstalling/reinstalling R, Rtools, RStudio, reinstalling libraries, updating them, I've tried launching RStudio as Administrator, I've tried changing computer.
The last thing I tried is this:
uninstalling R, Rtools and RStudio
deleting .RData and .Renviron files in the Documents folder
deleting all libraries
downloading R (latest version) from CRAN webpage and installing it as Administrator
downloading Rtools (latest version from webpage) and installing it as Administrator
creating the .Renviron file as described here
downloading RStudio (latest version from webpage) and installing it as Administrator
installing BiocManager as described here (when asked to update Matrix library I said NO, I thought it could be the problem)
installing gRbase, gRim, gRain libraries as described here (when asked to update fansi library I said NO because it said "There are binary versions available but the source versions are later", I thought it could be the problem)
Tried again the lines of code
Still got the problem, R session aborted again.
A friend of mine doing a similar project used gRbase::stepwise function, so I inserted his code in the console and the function worked. So I think the problem might be the object of the function, graph.MyGraph. The cmod function works fine, so maybe there's a problem with gRbodyfat, which is used to build graph.MyGraph.
If I run these lines (I tried changing the dataset, I used BodyFat instead of gRbodyfat):
graph.MyGraph <- cmod(~.^., data = BodyFat)
AIC.MyGraph <- gRbase::stepwise(graph.MyGraph)
I get the following error:
Error in dim(res) <- c(NSEL, NSET) :
dims [product 210] do not match the length of object [14]
Don't know what to do.
EDIT:
I've tried debugging gRbase::stepwise function and I get this:
The problem appears to be the iModel function.
EDIT:
I've discovered that if I use graph.MyGraph <- cmod(~.^1, data = gRbodyfat) the gRbase::stepwise function works fine.

How do I deal with an error message while installing a package?

I am brand new to this so please forgive my inexperience...I'm trying to learn.
I'm attempting to install an R package called "Doublet Finder" using the specified code given on the Github site.
When I do this, I get this error immediately:
Error in rbind(info, getNamespaceInfo(env, "S3methods")) :
number of columns of matrices must match (see arg 2)
Being new to R, I'm not sure what this error means and when I google this something similar comes up and the individual removed and re-installed ALL of their libraries...that seems crazy. Does anyone have advice on what this could be, how to fix it, or why the package won't install?
Your problem seems to be fairly similar to this one. It might be the case that the dependencies (packages that Doublet Finder relies on) are outdated. What you can try is to follow these steps to uninstall and reinstall all packages with the hope that by updating packages there isn't a version mismatch.
This code is copied from the website above:
ip <- as.data.frame(installed.packages(lib.loc = .libPaths()[1]),
stringsAsFactors = FALSE)
head(ip)
str(ip)
path.lib <- unique(ip$LibPath)
# create a vector with all the names of the packages you want to remove
pkgs.to.remove <- ip[,1]
head(pkgs.to.remove)
str(pkgs.to.remove)
sapply(pkgs.to.remove, remove.packages, lib = path.lib)
sapply(pkgs.to.remove, install.packages, lib = path.lib)

GoogleVis, Geomap Plot error

When I want to create the map using the gvisGeoMap() from googleVis, I get error:
## Using the google visualization API with R
library(googleVis)
input<- read.csv("data.csv")
select<- input[which(input$Subgroup=="Total 5-14"),]
select<- input[which(input$Subgroup=="Total 5-14 yr"),]
Map<- data.frame(select$Country.or.Area, select$Value)
names(Map)<- c("Country", "Percentage")
Geo=gvisGeoMap(Map, locationvar="Country", numvar="Percentage",
options=list(height=350, dataMode='regions'))
plot(Geo)
#starting httpd help server ... done
#Error in ifelse(interactive(), getOption("browser"), "false") :
#replacement has length zero
The above is the error in the "RGui". The error message in "RStudio" is differet:
#object of type 'closure' is not subsettable
and the browser does not fire at all. The HTTP server works fine since I can simply call help pages.( for example ?googleVis will fire up the browser and give the help page). The "Geo" object in the code above is fine and contains the html code only that the plot() does not do what it is supposed to do (I can manually run the html file in the temp folder and see the results). The example above is available here.
I would appreciate your clues.
Thank you
This is the result of correspondance with the the Authors of the packages. It seems that there was a bug that prevented the plot to work properly. The released a new version. You can find the link below.
TQ
.....
Yesterday evening I realised that with version 0.3.0 of googleVis I unfortunately introduced a bug in RStudio and R on Windows.
The bug has been fixed already and a new version (0.3.1) is available from our project site (here is the link), but not on CRAN yet.
I have put a note on my blog (here is the link) to inform others as well.
I hope this helps.
Best regards
Markus

How to correct for "Error in nullmodel(comm, method) : could not find function "list2env" in the vegan package

I'm busy exploring the package vegan for R, using it to calculate nestedness of community matrices and null models. I'm particularly interested in using the permat functions as well as Oecosimu.
However, when running my program I obtained the following errors:
Error in nullmodel(comm, method) : could not find function "list2env"
Error in nullmodel(m, ALGO) : could not find function "list2env"
I then even ran an example (given below) of how to use these functions given by the R help function, and even these examples gave the same error. Am I suppose to import something else in order to use these functions or how do I go about fixing this?
Examples:
m <- matrix(c(
1,3,2,0,3,1,
0,2,1,0,2,1,
0,0,1,2,0,3,
0,0,0,1,4,3
), 4, 6, byrow=TRUE)
x1 <- permatswap(m, "quasiswap")
summary(x1)
x2 <- permatfull(m)
summary(x2)
x3 <- permatfull(m, "none", mtype="prab")
x3$orig
summary(x3)
x4 <- permatfull(m, strata=c(1,1,2,2))
summary(x4)
Technically, this is a bug in the development version of Vegan on R-Forge. We were failing to declare a dependency on R versions >= 2.12 in DESCRIPTION. I have checked in the relevant change to the source tree to fix this but it will take a day or so before the tarball and binaries are rebuilt by R-Forge.
That said, you should probably update your R to something more recent. Or use the versions of those functions provided in Vegan 2.0-x on CRAN.
list2env is part of R base, which means it comes with the distribution, not in an add-on package. So if you don't have it you're probably either running an old version of R or have a broken installation. The example worked fine for me, with R 2.12.1 and vegan 2.1-0.
Your code works for me without an error message
The most probable cause of your error is your using old versions of R, vegan or permute
The R news for changes says
CHANGES IN R VERSION 2.12.0: NEW FEATURES:
o New list2env() utility function as an inverse of
as.list(<environment>) and for fast multi-assign() to existing
environment. as.environment() is now generic and uses list2env()
as list method.
CHANGES IN R VERSION 2.12.1: BUG FIXES:
o When list2env() created an environment it was missing a PROTECT
call and so was vulnerable to garbage collection.
CHANGES IN R VERSION 2.13.0: NEW FEATURES:
o list2env(envir = NULL) defaults to hashing (with a suitably sized
environment) for lists of more than 100 elements.
So update your version of R and the packages and try again.

Resources