R, mapply , ggplot : EXPR must be a length 1 vector

后端 未结 1 840
感动是毒
感动是毒 2021-01-28 08:10

I am trying plot the subsets of a table using ggplot and gridExtra. But I have bumbed in the following error EXPR must be a length 1 vector.

I could come up with any si

相关标签:
1条回答
  • 2021-01-28 08:38

    Change

    mplot <- mapply(p,dt2[,zone1],dt2[,zone2])
    

    to

    mplot <- mapply(p,dt2[,zone1],dt2[,zone2], SIMPLIFY=FALSE)
    

    or

    mplot <- Map(p,dt2[,zone1],dt2[,zone2])
    

    mapply() will attempt to coerce it's result to a matrix if the dimensions of the returned objects match up, however, in this case you will always want a list. You can either set the SIMPLIFY= parameter to false, or use Map() which always returns a list.

    0 讨论(0)
提交回复
热议问题