ggplot 'non-finite values' 错误
ggplot 'non-finite values' error
我有一个如下所示的 R 数据框 (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
...
我想使用 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")
但它会产生此警告:
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”
在您工作的 example plot here 中,较高的 n / total
处有很长的尾巴,因此需要使用 xlim()
。尝试在不改变 x-axis 的限制的情况下制作你的情节;在你的情况下你可能根本不需要调整它。
ggplot(df, aes(n/total, fill = blogger)) +
geom_histogram(show.legend = FALSE) +
facet_wrap(~blogger, ncol = 2, scales = "free_y")
我有一个如下所示的 R 数据框 (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
...
我想使用 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")
但它会产生此警告:
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”
在您工作的 example plot here 中,较高的 n / total
处有很长的尾巴,因此需要使用 xlim()
。尝试在不改变 x-axis 的限制的情况下制作你的情节;在你的情况下你可能根本不需要调整它。
ggplot(df, aes(n/total, fill = blogger)) +
geom_histogram(show.legend = FALSE) +
facet_wrap(~blogger, ncol = 2, scales = "free_y")