Using `geom_line()` with X axis being factors

后端 未结 1 578
Happy的楠姐
Happy的楠姐 2020-11-30 03:43

Suppose I have a dataframe:

hist <- data.frame(date=Sys.Date() + 0:13,
                   counts=1:14)

I want to plot the total count ag

相关标签:
1条回答
  • 2020-11-30 04:18

    If I understand the issue correctly, specifying group=1 and adding a stat_summary() layer should do the trick:

    ggplot(hist, aes(x=weekday, y=counts, group=1)) +
    geom_point(stat='summary', fun.y=sum) +
    stat_summary(fun.y=sum, geom="line")
    

    enter image description here

    0 讨论(0)
提交回复
热议问题