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. Thanks, Spencer R version 3.1.0 (2014-04-10) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] gridBase_0.4-7 raster_2.2-31 sp_1.0-15 mapdata_2.2-3 maps_2.3-7 [6] Ecfun_0.1-1 sos_1.3-8 brew_1.0-6 loaded via a namespace (and not attached): [1] lattice_0.20-29 tools_3.1.0 [[alternative HTML version deleted]]
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. Duncan Murdoch