tidyr::gather vs. reshape2::melt on matrices

前端 未结 1 909
無奈伤痛
無奈伤痛 2021-01-11 18:18

I\'ve been a long time user of reshape2::melt in a rather non-standard way: I\'m running numeric experiments and get a matrix as a result. I then melt it and pr

相关标签:
1条回答
  • 2021-01-11 18:41

    Perhaps a better answer will emerge, but in the meantime, I'll convert my comments to an answer:

    Quoting from the README to "tidyr":

    Note that tidyr is designed for use in conjunction with dplyr, so you should always load both.

    ... and from the README to "dplyr":

    dplyr is the next iteration of plyr, focussed on tools for working with data frames (hence the d in the name).

    As such, it sort of makes sense to not have methods for matrices.


    Since gather already wraps around melt, if you really wanted a matrix method, you can save yourself writing a custom function and just do something like:

    gather.matrix <- reshape2:::melt.matrix
    
    0 讨论(0)
提交回复
热议问题