group by two columns in ggplot2

后端 未结 3 1485
遥遥无期
遥遥无期 2020-12-01 00:09

Is it possible to group by two columns? So the cross product is drawn by geom_point() and geom_smooth()?

As example:

frame          


        
3条回答
  •  日久生厌
    2020-12-01 00:18

    Why not just paste those two columns together and use that variable as groups?

    frame$grp <- paste(frame[,1],frame[,2])
    

    A somewhat more formal way to do this would be to use the function interaction.

提交回复
热议问题