1

我正在尝试ggbiplotggfortify包中使用。它似乎工作正常,但我收到如下警告消息,

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

我有没有采取任何错误的步骤,或者它是一个错误。

4

1 回答 1

1

根据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")
于 2017-03-20T20:42:12.163 回答