js css html

2. 关于ggplot绘图公式复盘的一些问题1

2022-08-25  本文已影响0人  心惊梦醒
> summary(ggplot(economics, aes(date, unemploy)) + geom_line())
data: date, pce, pop, psavert, uempmed, unemploy [574x6]
mapping:  x = ~date, y = ~unemploy
faceting: <ggproto object: Class FacetNull, Facet, gg>
    compute_layout: function
    draw_back: function
    draw_front: function
    draw_labels: function
    draw_panels: function
    finish_data: function
    init_scales: function
    map_data: function
    params: list
    setup_data: function
    setup_params: function
    shrink: TRUE
    train_scales: function
    vars: function
    super:  <ggproto object: Class FacetNull, Facet, gg>
-----------------------------------
geom_line: na.rm = FALSE, orientation = NA
stat_identity: na.rm = FALSE
position_identity 
# 下面的这些写法都是等价的
p <- ggplot(mpg, aes(displ, hwy)) + geom_point()
# 单边公式
p1 <- p + facet_wrap(~cyl+vs)
# 字符串向量
p2 <- p + facet_wrap(c("cyl","vs"))
# vars()引用的变量名,这个函数必须实在数据上下文中使用,单独无法使用?
p3 <- p + facet_wrap(vars(cyl,vs))
# 另外,可以使用表达式,先买个坑......
上一篇下一篇

猜你喜欢

热点阅读