问题
I have some data that I'm trying to build some boxplots with, but I'm getting this error:
Warning message: Removed 1631 rows containing non-finite values (stat_boxplot).
There are no NA
values and all the data seems fine. How can I fix this as these are certainly valuable points in my data and should be extended by the whiskers?
Data
The data is fairly large, and I couldn't get a smaller subsample to produce the errors, so I'll just post the original data.
dat.rds
ggplot2
dat <- readRDS("./dat.rds")
ggplot(dat, aes(x = factor(year), y = dev)) + geom_boxplot() + ylim(-40, 260)
Edit
I was able to get it to work in boxplot
with `range = 6'. Is there a way to do this in ggplot?
boxplot(dev~year, data = d, range = 6)
回答1:
Remove the ylim
restriction and use the coef
argument of geom_boxplot
, then it works fine:
library(ggplot2)
download.file(url = "https://www.dropbox.com/s/5mgogyclhim6hom/dat.rds?dl=1", tf <- tempfile(fileext = ".rds"))
dat <- readRDS(tf)
ggplot(dat, aes(x = factor(year), y = dev)) +
geom_boxplot(coef = 6)
来源:https://stackoverflow.com/questions/34602872/how-to-remove-dots-and-extend-boxplots-in-ggplot2