我想用上面的数据做一个直方图,数据显示了某个国家的人均收入。使用这个命令我不断得到那个
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/