5

I found this expression while working on ggplot.

qplot(carat, ..density.., data = diamonds, facets = color ~ ., geom = "histogram", binwidth = 0.1, xlim = c(0, 3))

How is ..density.. interpreted by R?

Clearly it is not a variable and it is processed inside the function to convey that we want to use the density but I would like to undertand how it works at the language level.

mottalrd
  • 4,390
  • 5
  • 25
  • 31

1 Answers1

4

Normally, aesthetics are a 1:1 mapping to a column in the input data.frame. In this case, density is an output of the binning for the histogram. So, this the ggplot2 way of referring to certain derivatives that are a by product of an aggregation, such as the binning for a histogram in this case.

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149