2

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)

enter image description here

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)

enter image description here

Vedda
  • 7,066
  • 6
  • 42
  • 77

1 Answers1

6

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) 

enter image description here

lukeA
  • 53,097
  • 5
  • 97
  • 100
  • It's still showing up for me. – Vedda Jan 05 '16 at 01:43
  • @Amstell it works for me, it shouldn't show an error. – ytk Jan 05 '16 at 01:45
  • You're right, it doesn't show the error, but it's still showing the dots. I don't understand why those are showing up when they should be included in the boxplot – Vedda Jan 05 '16 at 01:46
  • 2
    If you don't want the outliers (i.e. dots) to show up, you can e.g. use `geom_boxplot(outlier.shape=NA)` (I'm using ggplot2 2.0.0 according to `packageVersion("ggplot2")`). – lukeA Jan 05 '16 at 01:48
  • @Amstell It is not clear what you want/don't want. –  Jan 05 '16 at 01:48
  • What if I want those outliers included? I'm trying to show the shocks that are occuring the data and this is missing it – Vedda Jan 05 '16 at 01:49
  • @Amstell If there are outliers (greater than 75% + 1.5xIQR and lower than 25% - 1.5xIQR), no. –  Jan 05 '16 at 01:49
  • @Pascal I've updated my question to include how I got it working in `boxplot` – Vedda Jan 05 '16 at 02:00
  • 1
    @lukeA I updated your answer according to OP edit. –  Jan 05 '16 at 02:11