Hi, Duncan:

On 7/3/2014 12:25 PM, Duncan Murdoch wrote:
On 03/07/2014 2:55 PM, Spencer Graves wrote:
I get inconsistent results from "[.data.frame". I've so far been
unable to create a simple, replicable example nor a workaround. With
debug, I traced the problem to "rows <- rows[i]", line 131 in
"[.data.frame":  In this example, rows = 1:45, and rows[1:3] = 1:3, as
we expect.  However with i = 1:3, rows[i] = c(1, 2, 2):


Browse[4]> rows[1:3]
[1] 1 2 3
Browse[4]>i
[1] 1 2 3
Browse[4]>rows[i]
[1] 1 2 2



Absent better suggestions, I currently plan to try to simplify my
example as much as I can while retaining the error. Unfortunately, the
search path includes 19 packages (see below), so I expect this not to be
easy.  Other suggestions would be welcomed.

Are you computing i using floating point values? You may have 2.9999999 instead of 3; as an index, it is equivalent to 2, though it will print as 3.



      You identified it:


 str(i)
 num [1:3] 1 2 3
Browse[4]> as.integer(i)
[1] 1 2 2


      Thanks so much.
      Spencer


Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to