Skip to content

Commit

Permalink
fix bug of direction in trans_ordination of trans_env
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiLiubio committed Dec 11, 2023
1 parent 100c71e commit 8e350ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/trans_env.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ trans_env <- R6Class(classname = "trans_env",
colnames(df_sites)[1:2] <- c("x", "y")

multiplier <- vegan:::ordiArrowMul(scrs$biplot)
df_arrows<- scrs$biplot * multiplier
df_arrows <- scrs$biplot * multiplier
colnames(df_arrows) <- c("x", "y")
df_arrows <- as.data.frame(df_arrows)
eigval <- res_ordination$CCA$eig/sum(res_ordination$CCA$eig)
Expand Down Expand Up @@ -1451,9 +1451,9 @@ trans_env <- R6Class(classname = "trans_env",
mindis <- min(arr_dis)
k <- (b-a)/(maxdis - mindis)
norDis <- a + k * (arr_dis - mindis)
per <- abs(arr[,1]/arr[,2])
per <- abs(arr[, 1]/arr[, 2])
newx <- (((norDis*per^2) / (per^2 + 1)) ^ (1/2)) * sapply(arr[, 1], function(y) ifelse(y > 0, 1, -1))
newy <- (newx/per) * sapply(arr[, 2], function(y) ifelse(y > 0, 1, -1))
newy <- (abs(newx)/per) * sapply(arr[, 2], function(y) ifelse(y > 0, 1, -1))
res <- data.frame(newx, newy)
colnames(res) <- colnames(arr)
res
Expand Down

0 comments on commit 8e350ea

Please sign in to comment.