我正在学习ggplot2,我不明白为什么这不起作用:
p <- ggplot(diamonds, aes(x = carat))
p <- p + layer(
geom = "point",
stat = "identity"
)
p
Error in as.environment(where) : 'where' is missing
Run Code Online (Sandbox Code Playgroud)
你知道为什么吗?
小智 7
我认为问题是你没有指定用于y值的内容.ggplot2没有与基本图形相同的默认值,用于根据索引值绘制点.要geom_point()和stat="identity"你一起使用需要:
p<-ggplot(diamonds, aes(x=carat, y=cut))
p+layer(geom="point", stat="identity")
Run Code Online (Sandbox Code Playgroud)
或更常见的
p+geom_point(stat="identity")
Run Code Online (Sandbox Code Playgroud)
或者你想要尝试绘制数据.
| 归档时间: |
|
| 查看次数: |
5126 次 |
| 最近记录: |