【发布时间】:2017-11-12 11:31:27
【问题描述】:
我正在尝试为一些数据创建一条黄土线
这里是一些代码:
library(ggplot2)
#rm(list=ls())
#gc()
#.rs.restartR()
###############################################################################
## Create some numbers for testing
m = 200
set.seed(123)
Aboard <- sample(1:m,m)
## some years to use
Years <- sort( trunc( runif( m, min=1931, max=1990 ) ) )
df <- data.frame(Aboard, Years)
graph <- ggplot(df, aes(Years, Aboard))
graph <- graph + stat_summary(fun.y=sum, geom="point", aes(size=..y..))
graph <- graph + theme_bw()
graph <- graph + stat_summary(fun.y=sum, geom="smooth", method="loess", alpha=0.01)
graph <- graph + theme(text = element_text(size=16))
graph <- graph + labs(title = "Some information that is here, from a computer,\nJune 2004")
graph <- graph + theme(plot.title = element_text(hjust=0.5))
graph <- graph + theme(plot.title = element_text(size=20))
graph <- graph + labs(x = "Year") + labs(y = "Information")
graph <- graph + stat_summary(fun.y=sum, geom="line")
graph
这是上面的输出:
我期待这条线
graph <- graph + stat_summary(fun.y=sum, geom="smooth", method="loess", alpha=0.01)
创建黄土线,但它只是适合数据点。
编辑
如果可能的话,我想要一个没有 tidyverse / dplyr 的解决方案,因为我没有使用这些
【问题讨论】:
标签: r ggplot2 statistics