DIG*_*SUM 11 r ggplot2 tidyverse tidytext
我有一个R dataframe(df),如下所示:
blogger; word; n; total
joe; dorothy; 17; 718
paul; sheriff; 10; 354
joe; gray; 9; 718
joe; toto; 9; 718
mick; robin; 9; 607
paul; robin; 9; 354
...
Run Code Online (Sandbox Code Playgroud)
我想使用ggplot2绘图n除以total每个blogger.
我有这个代码:
ggplot(df, aes(n/total, fill = blogger)) +
geom_histogram(show.legend = FALSE) +
xlim(NA, 0.0004) +
facet_wrap(~blogger, ncol = 2, scales = "free_y")
Run Code Online (Sandbox Code Playgroud)
但它产生了这个警告:
Warning message:
“Removed 1474 rows containing non-finite values (stat_bin).”Warning message in rep(no, length.out = length(ans)):
“'x' is NULL so the result will be NULL”
Run Code Online (Sandbox Code Playgroud)
Jul*_*lge 14
在你正在使用的示例图中,有更长的尾巴n / total,因此使用xlim().尝试制作您的绘图而不改变x轴的极限; 在你的情况下,你可能根本不需要调整它.
ggplot(df, aes(n/total, fill = blogger)) +
geom_histogram(show.legend = FALSE) +
facet_wrap(~blogger, ncol = 2, scales = "free_y")
Run Code Online (Sandbox Code Playgroud)