【问题标题】:ggforestplot error: Error in assertAndRetrieveTidyValue(x, mean) : argument "x" is missing, with no defaultggforestplot 错误:assertAndRetrieveTidyValue(x, mean) 中的错误:缺少参数“x”,没有默认值
【发布时间】:2022-08-07 14:09:26
【问题描述】:

我正在尝试使用ggforestplot 创建森林图,但收到错误消息:

assertAndRetrieveTidyValue(x, mean) 中的错误: 缺少参数“x”,没有默认值

library(ggforestplot)
library(tidyverse)
library(magrittr)

df_linear <-
  df_linear_associations %>%
  dplyr::arrange(name) %>%
  dplyr::filter(dplyr::row_number() <= 30)

# Forestplot
forestplot(
  df = df_linear,
  estimate = beta,
  logodds = FALSE,
  colour = trait,
  xlab = \"1-SD increment in cardiometabolic trait
  per 1-SD increment in biomarker concentration\"
)

    标签: r ggplot2 dplyr


    【解决方案1】:

    正如@Ilari Scheinin 所说的完全正确,当您加载forestplot 包并使用forestplot 函数时会发生此错误。在以下可重现的代码中,您可以看到执行此操作时发生错误:

    library(forestplot)
    library(ggforestplot)
    library(tidyverse)
    library(magrittr)
    
    df_linear <-
      df_linear_associations %>%
      dplyr::arrange(name) %>%
      dplyr::filter(dplyr::row_number() <= 30)
    
    # Forestplot
    forestplot::forestplot(
      df = df_linear,
      estimate = beta,
      logodds = FALSE,
      colour = trait,
      xlab = "1-SD increment in cardiometabolic trait
      per 1-SD increment in biomarker concentration"
    )
    #> Error in assertAndRetrieveTidyValue(x, mean): argument "x" is missing, with no default
    

    reprex package (v2.0.1) 于 2022 年 7 月 26 日创建

    确保卸载森林图!

    未加载时的代码forestplot

    当我运行您的代码时,没有错误。也许尝试重新启动您的环境并清理并重试。这是可重现的代码:

    library(ggforestplot)
    library(tidyverse)
    library(magrittr)
    
    df_linear <-
      df_linear_associations %>%
      dplyr::arrange(name) %>%
      dplyr::filter(dplyr::row_number() <= 30)
    
    # Forestplot
    forestplot(
      df = df_linear,
      estimate = beta,
      logodds = FALSE,
      colour = trait,
      xlab = "1-SD increment in cardiometabolic trait
      per 1-SD increment in biomarker concentration"
    )
    

    reprex package (v2.0.1) 于 2022 年 7 月 26 日创建

    【讨论】:

    • 非常感谢您的回复。我已尝试重新启动/清理环境,但仍然收到相同的错误。还有其他建议吗?
    • @DavidDearlove 也许尝试使用 install_github 重新安装 ggforestplot?
    • 上面的代码也适用于我。看起来错误来自另一个名为forestplot 的包,所以我猜你不仅加载了ggforestplot,还加载了forestplot。如果您将函数调用forestplot() 更改为显式ggforestplot::forestplot(),它将调用正确的函数,我想应该可以工作。
    • @IlariScheinin,你是对的!在加载 forestplot 库并使用该包运行函数时,我添加了一个可重现的示例!
    • @quinten 感谢您的回复。我认为问题是我同时加载了 forestplot() 和 ggforestplot() 包。也许有语法交叉?!
    猜你喜欢
    • 2017-12-09
    • 2020-07-04
    • 1970-01-01
    • 2018-09-10
    • 1970-01-01
    • 2021-09-17
    • 2016-06-08
    • 1970-01-01
    相关资源
    最近更新 更多