I’ve tried to run PGLS in R two different ways recently and I keep running into errors that I can’t find information about in the specific packages. I’m using RStudio, not the command line version in case that makes a difference.
The first way I tried, I’ve run before but now when I try to do it, I get an error “R session aborted and R encountered a fatal error”.
library(ape)
library(nlme)
thoracic <- X2024_Locomotion_for_R$Thoracic
locomotion <- X2024_Locomotion_for_R$Locomotor Type
pglsModel <- gls(thoracic ~ locomotion, correlation = corBrownian(phy = tree27),
data = X2024_Locomotion_for_R, method = “ML”)
I’ve determined the error occurs after the third line. The two columns that start with X2024 are imported into R from Excel. Thoracic is a quantitative list, locomotion is a qualitative list, and they’re long lists, which may be why I’m getting an error.
After the “R session aborted and R encountered a fatal error” message, I’ve heard that uninstalling and reinstalling R can help with this error, but I’ve done that twice and still get this error no matter what.
After getting this error, I tried another package after reading a PGLS tutorial online (which I can link if asked). I’ve been getting stuck at the second step though.
library(caper)
locomotion_PGLS <- comparative.data(tree27, X2024_Locomotion_for_R, X2024_Locomotion_for_R$Combined Binomial Name
, vcv=FALSE, vcv.dim=2, na.omit=TRUE, force.root=FALSE, warn.dropped=FALSE, scope=NULL)
I get this error: “Error in if (is.na(namesInd)) { : the condition has length > 1”. I looked up the error here and on the caper package’s webpage. I can’t find any information about this error occurring after using comparative.data in the package caper. The information I have been able to find about this error in other functions and packages doesn’t seem to match up with what I’m doing.
Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.