# [Rd] Looks like a bug in subsetting of a complicated object

From: Kjetil Halvorsen <kjetilbrinchmannhalvorsen_at_gmail.com>
Date: Wed, 01 Sep 2010 18:22:12 -0400

Code reproducing the problem follows:

library(RandomFields)

set.seed(123)

```sim0 <- GaussRF(x=seq(0, 100, by=1),
y=seq(0, 100, by=1),
grid=TRUE, model="spherical",
param=c(0, 1, 0, 10), trend=NULL, n=9, gridtriple=FALSE)

simmatrices <- function(arr) # arr must be an array of rank 3
{
d <- dim(arr)
n1 <- d[1]; n2 <- d[2] # we suppose d[3]==9
res <- vector(length=n1*n2, mode="list")
dim(res) <- c(n1, n2)
for (i in 1:n1) for (j in 1:n2) {
x1 <- arr[i, j, 1:3];x2 <- arr[i, j, 4:6]
x3 <- arr[i, j, 7:9]
res[[i, j]] <- x1%o%x1 + x2%o%x2 + x3%o%x3
}
res
}

```

sim1 <- simmatrices(sim0)

set.seed(234)
x <- sample(seq(0, 100, by=1), 101, replace=TRUE) y <- sample(seq(0, 100, by=1), 101, replace=TRUE) coo <- cbind(x=x, y=y)
coo <- unique(coo)

sim1.obs <- sim1[coo]

dim(coo)
length(sim1.obs)

> sessionInfo()
R version 2.11.1 (2010-05-31)
i686-pc-linux-gnu

locale:

``` [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
[3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8
[5] LC_MONETARY=C             LC_MESSAGES=en_US.utf8
[7] LC_PAPER=en_US.utf8       LC_NAME=C
```

[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] lattice_0.18-8 gstat_0.9-69 sp_0.9-66
[4] RandomFields_1.3.41

loaded via a namespace (and not attached):
[1] fortunes_1.3-7 grid_2.11.1 tools_2.11.1
>

Kjetil

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 01 Sep 2010 - 22:24:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 02 Sep 2010 - 09:10:54 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.