0
我使用ggplot2和閃亮來創建圖形,但是x軸上顯示的因素太多。閃亮/ R:線圖上的因素太多
output$housePlot <- renderPlot({
ggplot(data=houseratio, aes(x=Year, y=Ratio, group=Region, colour=Region)) +
geom_line() +
geom_point()
})
我試着讀這post,但我不能讓SEQ()的權利。我的數據是在長格式,如下所示:
Year Ratio Region
1983 Q1 2.9 Northern
1983 Q2 3 Northern
1983 Q3 3.1 Northern
1983 Q4 3 Northern
...
2015 Q2 5.1 UK
2015 Q3 5.1 UK
2015 Q4 5.2 UK
2016 Q1 5.2 UK
使用此代碼:
output$housePlot <- renderPlot({
ggplot(data=houseratio, aes(x=Year, y=Ratio, group=Region, colour=Region)) +
scale_x_discrete(breaks = seq(1, 1864, by = 4)) +
geom_line() +
geom_point()
})
所有因素消失!
我只需要每一年的表現,而不是單獨的宿舍。有什麼建議麼?
(感謝)
嘗試'scale_x_date'或'scale_x_datetime' http://docs.ggplot2.org/current/scale_date.html –