Closed skytguuu closed 2 years ago
Hi, it works fine in this example. Can you provide a minimal working example that shows the problem? Or am I misunderstanding the problem?
library(ggord)
library(vegan)
library(dplyr)
iris2 <- iris %>%
mutate(
Species = case_when(
Species == 'setosa' ~ 'spp1',
Species != 'setosa' ~ 'spp2'
)
)
# prcomp
ord <- prcomp(iris2[, 1:4])
p <- ggord(ord, grp_in = iris2$Species)
p
Hi,
Thanks for your reply. Actually, u misunderstood my question. In your case, the group spp1 and spp2 have more than 2 observations (row is more than 4, in your case the row is 150). The problem is if the row is no more than 4, it will report the error. The data is as followed:
Ah, I see. Problem is it's trying to create confidence ellipses for groups with less than three observations. Set ellipse = F
and you should be good to go.
And for what it's worth, I added an error message indicating the same if there's insufficient observations to create the ellipses.
library(ggord)
library(vegan)
library(dplyr)
iris2 <- iris %>%
mutate(
Species = case_when(
Species == 'setosa' ~ 'spp1',
Species != 'setosa' ~ 'spp2'
)
) %>%
.[c(1:2, 51:52),]
# prcomp
ord <- prcomp(iris2[, 1:4])
ggord(ord, grp_in = iris2$Species)
## Error in ggord.default(obs, vecs, axes, ...) :
## Insufficient observations for confidence ellipses, set ellipse = F to plot
Hi,
I found the parameter "grp_in" was only worked on more than 2 replicates. If I want to use 2 replicates for each group. It reported the error :"Error in names(ell) <-
*vtmp*
: 'names' attribute [3] must be the same length as the vector [0]". Could you improve the parameter to work well with 2 replicates?Thanks!