Skip to content

position_dodge2 with NA values causes errors #2905

Closed
@espher1987

Description

@espher1987

I have one problem with geom_boxplot works. First I am using date type data and try not to plot all my data, only a part.

First I load my packages

library(dplyr)
library(ggplot2)
library(tibble)
library(quantmod)

I am using getSymbols to get my data

yahoo <- getSymbols(auto.assign = F,Symbols = "QQQ")
chartSeries(yahoo,subset = "last 3 month")

I shape my data to use it in ggplot

df <- yahoo %>%
  as.data.frame() %>% 
  rownames_to_column() %>% 
  rename("time" = "rowname") %>% 
  mutate(time = as.Date(time))

I set my date limits

l <- c(df$time[10],df$time[100])

Then I try to plot it

ggplot(data = df) +
  geom_boxplot(aes(x = time,
                   lower  = QQQ.Close,
                   upper  = QQQ.Open,
                   ymin   = QQQ.Low,
                   ymax   = QQQ.High,
                   middle = QQQ.Open),
               stat = "identity") +
  scale_x_date(limits = l)

and I get error:

Error in if (df$xmin[i] >= df$xmax[i - 1]) { :
valor ausente donde TRUE/FALSE es necesario


i get this error using ggplot2 3.0.0. I try this code in ggplot2 2.2.1 and i don't get any error. As far i search this can be related to "position_dodge2".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorpositions 🥇

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions