'Use of .BY and .EACHI in the data.table package
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 not seen a lot of examples of people using it, but the documentation implies that is is useful in plotting.
For example, the following code seems to work quite well (showing a plot for each of the species and assigning the right title to each plot) in data.table 1.9.3:
iris <- data.table(iris)
iris[,plot(Sepal.Length ~ Sepal.Width, main = unlist(.BY)), by = Species]
While this code does not work as intended by me:
iris[ , plot(Sepal.Length ~ Sepal.Width, main = .BY), by = Species]
Why are these two different? From the comments, it does not seem to be an issue in data.table 1.9.2. In what other ways might it be useful to use the .BY statement? How is this different compared to the .EACHI statement?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
