Sorry if my question has been answered somewhere already, but all the other posts about "Aesthetics must be either length 1 or the same as the data" did not help me.
I'm trying to run the following code, but it gives this error: Error: Aesthetics must be either length 1 or the same as the data (1): x
library(tidyverse)
demand <- function(q) (q - 10)^2
supply <- function(q) q^2 + 2*q + 8
x <- 0:5
chart <- ggplot() +
stat_function(aes(x), color = "Demand", fun = demand) +
stat_function(aes(x), color = "Supply", fun = supply)
chart
What's wrong here?
The output should look like this:

