Two columns x-axis in ggplot2 (point first, point second)
I have quarterly data as follows (the key represents a quarter of a quarter):
tic saleq key
1 AAPL 1346.202 1990-2
2 AAPL 1364.760 1990-3
3 NOK 1354.090 1990-4
Since it is now in one column, I can plot the line with the combined column as the x-axis:
p <- ggplot(example, aes(x = key, y = saleq))
p + geom_line(aes(color=tic, group=tic)) + ylab("Quarterly sales")
However, this (logically) generates many duplicate "year" values (i.e. column x is littered 2014-1, 2014-2)
I would like to be able to plot this with ggplot2, "grouping" by year, and then displaying the quarter just above it on the x-axis. Similar to plotting a line graph in Excel, as with this data. Is this possible in ggplot2?
I was redirected to this question which is trying something similar. However, this leaves out naming multiple "groups" of x-values: should I dynamically calculate where the midpoint of each year is (to account for the number of data quarters per year?)
source to share
No one has answered this question yet
See similar questions:
or similar: