Metaprogramming with ggplot2

后端 未结 2 1281
别跟我提以往
别跟我提以往 2020-12-19 16:18

I\'ve been trying to cut down on the amount of copying and pasting required to make a large number of charts with slightly differing functions / slices of the data.

2条回答
  •  一个人的身影
    2020-12-19 16:24

    facet_grid() takes a formula object, and you can create a formula object from a string with as.formula(). So you should be able to do something like:

     facet_grid(as.formula(paste(rowfacet, "~", colfacet)))
    

提交回复
热议问题