0

I am trying to create a weighted scatter plot where the day of the week is on the Y-axis and the hour of the day is on the X-axis, with size = n of tweets. I have the following code:

data %>%
mutate(day_week = wday(created_at)) %>%
count(screen_name, hour = hour(with_tz(created_at, "CET"))) %>%
ggplot(aes(day_week, hour, size = n)) +
geom_point() +
labs(x = "Hour of day (CET)",
   y = "Day of the week") + theme_bw()

Error in FUN(X[[i]], ...) : object 'day_week' not found

The variable created_at is of class POSIXct and POSIXt.

How do I create this plot without the error?

mundos
  • 459
  • 6
  • 14
  • 1
    You didn't keep `day_week` as part of the dataset when counting. Maybe you meant to `group_by` prior to `count`? To troubleshoot, break up the pipe and look at the dataset before passing it to `ggplot` to make sure it is as you expected. – aosmith Sep 08 '17 at 17:08
  • 1
    Please add a minimal example dataset when posting questions, cfr. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. – 67342343 Sep 08 '17 at 17:11

0 Answers0