A function was masked.

Hello there,
I am going to do a data report, so I used ggplot to make a plot, but it seems there are some errors.


library(reprex)

delays <- read_csv("http://vis.cwick.co.nz/data/all-summary.csv")




delays$Origin <- factor(delays$Origin, levels = c("IAH", "HOU"))
ggplot(delays, aes(DepHour, DayOfWeek)) +
  geom_tile(aes(fill = prop_over_15)) + 
  facet_wrap(~Origin,dir='v')+
  scale_x_continuous("Departure time", 
                     breaks = c(0, 6, 12, 18, 24),
                     labels = c("midnight", "6am", "noon", "6pm", "midnight"),
                     expand = c(0, 0),
                     limits = c(0, 23)) +
  scale_y_discrete("Departure day") +
  geom_rect(aes(
    xmin = 18,
    xmax = 22.5,
    ymin = 'Mon',
    ymax = 'Sun'
  ),
  fill = NA,
  color = "blue",
  linetype = 3,
  size = 1
  )+
  labs(title = "IAH has best evening ontime depatures over HOU",
       subtitle = "Based on all departing flights from George Bush Intercontinental Airport (IAH) \nand Houston(HOU) in 2011") +
  guides(color = "none") + 
  theme_classic() +
  theme(axis.ticks.y = element_blank(), axis.line.y = element_blank(), axis.title.x = element_text(color = "black", size = 14, face = "bold"),
        axis.title.y = element_text(color = "black", size = 14, face = "bold"),
        axis.text.x = element_text(color = "black",face = "bold"),
        axis.text.y = element_text(color = "black",face = "bold")
  ) + coord_equal()+
scale_fill_continuous_sequential(
  name = "Flights delayed \nmore than 15 mins", 
  palette = "YlOrRd", 
  breaks = c(0, .25, 0.5, .75, 1), 
  labels = c("0%", "25%", "50%", "75%", "100%"), 
  expand = c(0, 0),
  guide = "colorbar")

There is the message said:
Error in scale_fill_continuous_sequential(name = "Flights delayed \nmore than 15 mins", :
No "scale_fill_continuous_sequential" such a function.

And I remember some days ago here was a message said this function was masked and "The following objects are masked by ‘.GlobalEnv’", so I deleted all the R and related files from my computer and reinstall all of them.

But it still not working well, my R is 4.02, and R tools is 4.00.

Thank you guys!

There's no such function in ggplot2 so not sure how you arrived at this code.
Here is some documentation that will hopefully be helpful to you.

Because this "scale_fill_continuous_sequential is masked" was shown there right after "The following objects are masked by ‘.GlobalEnv’".

I think you are likely mistaken about that....but its not worth an argument.
I recommend the function linked to in the link

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.