Closed Conny42 closed 2 years ago
Hi @lumberjane, it does not make sense to plot an RDA model with only one continous explanatory variable. The model has only one constrained axis (RDA1) and it is impossible to plot in two or more dimensions.
Thanks @fawda123 - yes, I know that the model has only one constrained axis, but why not plot the first unconstrained axis (PC1) against the RDA1 axis, as done in the plot.cca function from the vegan library?
@lumberjane does something like this work? I would not be able to include this in the package, but you can use this script to create some custom plots that use the default method for ggord.
library(ggord)
library(vegan)
data(dune)
data(dune.env)
model<-rda (dune ~ Condition(Moisture) + A1, scale=F,data = dune.env)
# pick your axes
axis1 <- 'RDA1'
axis2 <- 'PC1'
# data to plot, site and species data
obs1 <- data.frame(ord_in$CCA$wa[, axis1])
obs2 <- data.frame(ord_in$CA$u[, axis2])
obs <- cbind(obs1, obs2)
names(obs) <- c(axis1, axis2)
addpts1 <- data.frame(ord_in$CCA$v[, axis1])
addpts2 <- data.frame(ord_in$CA$v[, axis2])
addpts <- cbind(addpts1, addpts2)
names(addpts) <- c(axis1, axis2)
# vectors for constraining matrix
constr <- data.frame(ord_in$CCA$biplot[, axis1, drop = F])
constr <- cbind(constr, 0)
names(constr) <- axes
ggord.default(obs, vecs = constr, axes, addpts = addpts, ptslab = T)
Function ggord throws an error then plotting a RDA result. Everything works fine if I have more than one explanatory variable in my model. However, with just one explanatory variable I got the error: Error in ord_in$CCA$wa[, axes] : subscript out of bounds (?)
Any help is very much appreciated....
Created on 2022-01-26 by the reprex package (v2.0.0)