来自 ggfortify::ggbiplot 的警告消息

Warning message from ggfortify::ggbiplot

我正在尝试使用来自 ggfortify 包的 ggbiplot。它似乎工作正常,但我收到如下警告消息,

mdl <- pls::plsr(mpg ~ ., data = mtcars, scale = T)
scrs <- data.frame(pls::scores(mdl)[])
loads <- data.frame(pls::loadings(mdl)[])

ggfortify::ggbiplot(scrs, loads, 
  label.label = rownames(scrs), asp = 1, label = T, label.size = 3,
  loadings = T, loadings.label = T, loadings.label.label = rownames(loads))

Warning messages:
1: In if (value %in% columns) { :
  the condition has length > 1 and only the first element will be used
2: In if (value %in% columns) { :
  the condition has length > 1 and only the first element will be used

我是不是走错了一步,还是bug。

根据 ggbiplot 文档,label.label= 参数需要从中提取名称的列名;它不期望名称向量。 loadings.label.label= 也是如此。 (ggplot 和大多数 tidyverse 函数不太喜欢行名——最好让它们成为一个合适的列)

scrs$ID <- rownames(scrs)
loads$ID <- rownames(loads)
ggfortify::ggbiplot(scrs, loads, 
  label.label = "ID", asp = 1, label = T, label.size = 3,
  loadings = T, loadings.label = T, loadings.label.label = "ID")