I don't think this is a bug. It looks like it is intended if you see the source code of the two functions: ggplot
and geom_point
:
For ggplot
:
> getAnywhere(ggplot.data.frame)
A single object matching ‘ggplot.data.frame’ was found
It was found in the following places
registered S3 method for ggplot from namespace ggplot2
namespace:ggplot2
with value
function (data, mapping = aes(), ..., environment = globalenv())
{
if (!missing(mapping) && !inherits(mapping, "uneval"))
stop("Mapping should be created with aes or aes_string")
p <- structure(list(data = data, layers = list(), scales = Scales$new(),
mapping = mapping, theme = list(), coordinates = coord_cartesian(),
facet = facet_null(), plot_env = environment), class = c("gg",
"ggplot"))
p$labels <- make_labels(mapping)
set_last_plot(p)
p
}
<environment: namespace:ggplot2>
And geom_point
:
> geom_point
function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
na.rm = FALSE, ...)
{
GeomPoint$new(mapping = mapping, data = data, stat = stat,
position = position, na.rm = na.rm, ...)
}
<environment: namespace:ggplot2>
If you look at the ellipsis argument ...
you will see that it is not used in the ggplot
function. So, your use of the argument subset=.()
is not transferred or used anywhere. It does not give any errors or warnings however because of the existence of the ellipsis in the ggplot
function.
On the other hand the geom_point
function uses the ellipsis and transfers it to GeomPoint$new
where it is used. In this case your subset=.()
argument is transferred to GeomPoint$new
where it is used, producing the result you want.