I've tried to place multiple geom_area function with for y axis values with Year as the x-axis. I'm very new to R so sorry if this is something very simple.
What's the best way to stack these area charts?
c <- ggplot(data=fbi, aes(x=Year))
c + geom_area(aes(y=Aggravated..assault, fill="Orange")) +
geom_area(aes(y=Robbery, fill="Blue")) +
geom_area(aes(y=Rape..legacy..definition4., fill="Red")) +
geom_area(aes(y=Murder.and.nonnegligent..manslaughter, fill="Green"))
This is the structure of the data for added context:
$ Year : num 1997 1998 1999 2000 2001 ...
$ Population : num 2.68e+08 2.70e+08 2.73e+08 2.81e+08 2.85e+08 ...
$ Violent.crime : num 5.37e+08 5.42e+08 5.47e+08 5.64e+08 5.72e+08 ...
$ Violent..crime..rate. : num 8.07e+08 8.14e+08 8.21e+08 8.47e+08 8.59e+08 ...
$ Murder.and.nonnegligent..manslaughter : int 18208 16974 15522 15586 16037 16229 16528 16148 16740 17309 ...
$ Murder.and..nonnegligent..manslaughter..rate.: num 6.8 6.3 5.7 5.5 5.6 5.6 5.7 5.5 5.6 5.8 ...
$ Rape..revised..definition3. : int NA NA NA NA NA NA NA NA NA NA ...
$ Rape..revised..definition...rate : num NA NA NA NA NA NA NA NA NA NA ...
$ Rape..legacy..definition4. : int 96153 93144 89411 90178 90863 95235 93883 95089 94347 94472 ...
$ Rape..legacy..definition...rate : num 35.9 34.5 32.8 32 31.8 33.1 32.3 32.4 31.8 31.6 ...
$ Robbery : int 498534 447186 409371 408016 423557 420806 414235 401470 417438 449246