【问题标题】:Warning message from ggfortify::ggbiplot来自 ggfortify::ggbiplot 的警告消息
【发布时间】:2017-03-20 20:09:20
【问题描述】:

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

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

我是否采取了错误的步骤或者是错误。

【问题讨论】:

    标签: r ggplot2 warnings ggbiplot ggfortify


    【解决方案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")
    

    【讨论】:

    • 谢谢,我尝试了与rowname_to_column 相同的操作,将行名添加为data.frame 的第一行。这就是我遇到问题的地方。
    猜你喜欢
    • 2017-08-23
    • 1970-01-01
    • 2012-06-20
    • 2014-05-31
    • 1970-01-01
    • 2019-07-03
    • 2016-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多