R 错误:应使用'aes()或'aes_u()创建映射`
我发现了错误 错误:应使用R 错误:应使用'aes()或'aes_u()创建映射`,r,R,我发现了错误 错误:应使用aes()或aes_389;()创建映射 2个问题,您不需要数据参数,因为它已经通过管道输入。正如@rpolicastro所说,只有“身份”应该用引号括起来: df %>% group_by(state_name) %>% summarise(TotalPopulation = mean(population_total)) %>% ggplot(data=df, aes(x= state_name, y=TotalPopulation)) +
aes()或aes_389;()创建映射
2个问题,您不需要数据
参数,因为它已经通过管道输入。正如@rpolicastro所说,只有“身份”应该用引号括起来:
df %>%
group_by(state_name) %>%
summarise(TotalPopulation = mean(population_total)) %>%
ggplot(data=df, aes(x= state_name, y=TotalPopulation)) +
geom_bar("stat=identity")
让我们重新创建mtcars的问题
df %>%
group_by(state_name) %>%
summarise(TotalPopulation = mean(population_total)) %>%
ggplot(aes(x= state_name, y=TotalPopulation)) +
geom_bar(stat="identity")
有两点需要解决:
- 您使用管道传递数据,因此应删除
data=mtcars
- 报价应该是
geom\u bar(stat=“identity”)
而不是geom\u bar(“stat=identity”)
下面的代码生成一个绘图
mtcars %>%
group_by(cyl) %>%
summarise(TotalMpg = mean(mpg)) %>%
ggplot(data=mtcars, aes(x= cyl, y=TotalMpg)) +
geom_bar("stat=identity")
Error: Mapping should be created with `aes() or `aes_()`
geom_bar中只有“identity”应该在引号中。
mtcars %>%
group_by(cyl) %>%
summarise(TotalMpg = mean(mpg)) %>%
ggplot(aes(x= cyl, y=TotalMpg)) +
geom_bar(stat="identity")