How can I suppress “Transformation introduced infinite values” warnings in R? [duplicate]

喜你入骨 提交于 2021-01-29 07:13:38

问题


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?

Transformation introduced infinite values in continuous y-axis


回答1:


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)

  


来源:https://stackoverflow.com/questions/63522128/how-can-i-suppress-transformation-introduced-infinite-values-warnings-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!