Use of .BY and .EACHI in the data.table package

后端 未结 1 707
情话喂你
情话喂你 2020-12-17 03:37

I am trying to get a better grasp on how some of the special variables in the data.table package work. One of these is the .BY statement. I have

相关标签:
1条回答
  • 2020-12-17 04:20

    .BY is a named list containing the values of the by variables.

    Passing an unnamed list to main will work, however a named list will fail (wholly unrelated to data.table

    plot(1, main = list(1))
    # works....
    plot(1, main = list(s=1))
    # Error in title(...) : invalid graphics parameter
    

    There is a recent commit to data.table 1.9.3 which fixed a bug to do with naming in `.BY Closes bug #5415. .BY gets names attribute set properly in april this year.

    If you had more than 1 "by" variable, you would want to be able to concatenate some how

    perhaps

    iris[,plot(Sepal.Length~Sepal.Width,main=do.call(paste,.BY)),by=Species]
    

    will work (unless you have a column called collapse!)

    EACHI is completely unrelated to this. Please read the NEWS for data.table 1.9.3 for an understanding of this.

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