我在使用ggplot2和qplot函数时遇到了一个错误(请参阅下面的警告和错误),我不知道如何进行更改以便它可以正常工作。我看了一下与此问题相关的过去帖子,但仍无法更正代码。
有人可以给我一些建议吗?
> library(ggplot2)
Warning message: package ‘ggplot2’ was built under R version 3.2.5
> dodge <- position_dodge(width = .9)
> plot <- qplot(happening, target.looking_M, data=d.c2.subjects, stat="identity",
+ geom="bar", position=dodge,
+ ylab="Proportion of looks", xlab="happening",
+ fill=happening, colour=happening,
+ main="Proportion target looking by condition and testing phase for each single subject")
警告讯息:
1: `stat` is deprecated 2: `position` is deprecated
> plot <- plot + facet_grid(type ~ subjectname)
> plot
Error: stat_count() must not be used with a y aesthetic.
答案 0 :(得分:2)
正如警告所述,在stat
中不推荐使用qplot
这种方式。作为一般性建议,我不再依赖于qplot
并学习如何使用完整的ggplot
语法,因为这样可以为您提供更多功能。
为了完成这项工作,您可以使用geom = "col"
代替。 geom_col
是一个新的geom
,其行为类似于geom_bar(stat = "identity")
。