工作中总结的一些R语言的语句,以备不时之需,避免重复检索。有待补充整理收集。

  • R中ggplot绘图使添加的标题居中
ggplot(stage_data,aes(x=stage,y=num)) + 
    labs(title="Stage Distribution") +
    theme(plot.title = element_text(hjust = 0.5))
  • R中ggplot绘密度曲线
ggplot(origin_input, aes(x = xvalue)) + 
geom_histogram(position = "identity",alpha = 0.2,aes(y = ..density..))