gpt4 book ai didi

R 工作室直方图错误 : stat_bin() must not be used with a y aesthetic

转载 作者:行者123 更新时间:2023-12-05 05:11:53 25 4
gpt4 key购买 nike

enter image description here

我想用上面的数据做一个直方图,数据显示了某个国家的人均收入。使用这个命令我不断得到那个

Error: stat_bin() must not be used with a y aesthetic.

incomenew <- data_opdracht_income_per_person_xlsx %>%
gather("1990":"2018", key = "year", value = "income")
incomenew

incomenew$year <- as.numeric(incomenew$year)

incomenew$income <- as.numeric(incomenew$income)


dataexample3 <- incomenew %>%
filter(country == "Netherlands" | country == "China" | country == "Nigeria")

figure4 <- ggplot(data= dataexample3, mapping = aes(x=year, y=income))

figure4 + geom_histogram()

如何改变 y 不美观?

最佳答案

geom_histogram 将一个向量作为参数并将数据放入不同的“桶”或“箱”

你可能想要这样的东西:

figure4 <- ggplot(data= dataexample3, mapping = aes(x=year, y=income))
figure4 + geom_col(aes(color=country)

关于R 工作室直方图错误 : stat_bin() must not be used with a y aesthetic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54988738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com