force ggplot to evaluate counter variable

后端 未结 1 824
谎友^
谎友^ 2020-12-19 18:05

I ran into an interesting problem regarding how/when variables are evaluated in ggplot constructs.

The simplest example I can think of to reproduce this is the foll

相关标签:
1条回答
  • 2020-12-19 18:37

    The aes() specifically prevents evulation. If you want evaulation, you can use the standard-evaluation version aes_()

    panel=ggplot() + xlim(-1,11) + ylim(-1,11)
    for (i in c(1:10)) {
        panel=panel+geom_point(aes_(x=df$x[i],y=df$y[i]))
    }
    print(panel)
    
    0 讨论(0)
提交回复
热议问题