我想用上面的数据制作直方图,数据显示某个国家的人均收入。使用此命令,我不断得到
错误:stat_bin()不能与y美学一起使用。
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
不美观?
答案 0 :(得分:0)
geom_histogram
以一个向量作为参数,并将数据放入不同的“存储桶”或“容器”
您可能想要类似的东西:
figure4 <- ggplot(data= dataexample3, mapping = aes(x=year, y=income))
figure4 + geom_col(aes(color=country)