在泰坦尼克号数据集上使用 ggplot 时,我收到错误“计算美学问题。发生错误...找不到对象

问题描述 投票:0回答:0

这是错误代码后跟的代码。变量 new.title 已创建,然后在代码中使用,但无论出于何种原因,我都会收到错误消息,无法找到我错过的内容。

    data.combined$new.title <- as.factor(titles)

    ggplot(data.combined[1:891,], aes(x = new.title, fill = survived)) +
      geom_bar() +
      facet_wrap(~Pclass) + 
      ggtitle("Surival Rates for new.title by pclass")

geom_bar()
中的错误: !计算美学时出现问题。

ℹ 第一层出现错误

FUN()
中的错误引起:

!未找到对象“new.title”

运行

rlang::last_error()
查看错误发生的位置。

我试图制作一个条形图来展示 Pclass 从泰坦尼克号沉没中幸存下来的情况。在重新映射乘客姓名的标题后,我创建了变量,然后尝试绘制结果。

我得到的不是情节,而是我分享的错误代码。

r ggplot2 geom-bar facet-wrap aesthetics
© www.soinside.com 2019 - 2024. All rights reserved.