我怎样才能抑制“转换引入的无限值"?R中的警告? [英] How can I suppress "Transformation introduced infinite values" warnings in R?

查看:27
本文介绍了我怎样才能抑制“转换引入的无限值"?R中的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个情节很棒.它拥有我需要的一切,而且 y=0 值在一个合理的位置,尽管是对数刻度.一切都很棒!

This plot is great. It has everything I need, and the y=0 value is in a sensible place despite the logarithmic scale. All is great!

library(ggplot2)
df <- data.frame(x=1:3, y=c(1, 0, 2))
print(ggplot(df, aes(x=x, y=y)) + geom_point() + scale_y_log10())

我怎样才能抑制这个警告,而且只有这个警告?

How can I suppress this warning, and only this warning?

变换在连续 y 轴上引入了无限值

Transformation introduced infinite values in continuous y-axis

推荐答案

您可以通过越界参数来处理它.请在下面找到代码.

you can handle it by out of bounds argument. Please find the code below.

 library(ggplot2)
df <- data.frame(x=1:3, y=c(1, 0, 2))
print(ggplot(df, aes(x=x, y=y)) + geom_point() + scale_y_log10(oob = scales::squish_infinite)

  

这篇关于我怎样才能抑制“转换引入的无限值"?R中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆