Bug 15718 - Warning when assigning using [<-.data.frame with empty vector of row indexes
Summary: Warning when assigning using [<-.data.frame with empty vector of row indexes
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.1.0
Hardware: x86_64/x64/amd64 (64-bit) Linux
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2014-03-19 23:08 UTC by Kirill Müller
Modified: 2014-03-21 21:38 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Kirill Müller 2014-03-19 23:08:34 UTC
The last statement of the following code produces a warning -- is this intentional?

> d <- data.frame(a=1)
> d[integer(), ]
> d[integer(), "a"]
> d[integer(), "a"] <- 2
Warning message:
In max(i) : no non-missing arguments to max; returning -Inf

Empty vectors of row indexes can arise when using which() on an all-FALSE selection vector. To me, the warning is misleading; it seems odd to require a special treatment of this corner case from the user, and using suppressWarnings() could mute other, desired, warnings.

I apologize if this has come up before, but I was unable to find anything related on the web.
Comment 1 Brian Ripley 2014-03-21 15:46:02 UTC
It was doing needless calculations in that case: I guess the author never considered anyone would do that.
Comment 2 Kirill Müller 2014-03-21 21:38:26 UTC
Confirmed. Thanks for the quick fix.