[R] Randomized Points in space/ saving model results
magono
nroyal01 at gmail.com
Mon Oct 31 06:51:37 CET 2011
Ok, to michael
Looking over what you posted I'm thinking this is the way forward but my
lack of experience using functions is getting in the way of accomplishing
the task. Examining the outputs into the functions and putting in my own
info is giving me a headache. Here's my thoughts at each step marked with
``````-
runif2d <- function(n = 100, xmin = 1, xmax = 2, ymin = 14, ymax = 15){
```````put in my bounding box coordinates above
stopifnot(all(xmax > xmin, ymax > min))
y <- runif(n, ymin, ymax)
x <- runif(n, xmin, xmax)
````````shall I enter the bounding box info again above in the y= and x= ?
cbind(x,y) }
`````Say I want to examine the resulting points created, how can I go about
this?
getdist <- function(inpoints, refpoints) {
``````` which of these is my .csv of predetermined coordinates to add to the
mix and which of these points to the generated points above?
# Takes in two 2 column matrices representing (x,y) coordinates
# and returns a matrix with all the distance pairs between them
stopifnot(all(is.matrix(inpoints), is.matrix(refpoints),
dim(inpoints)[2L] == 2L, dim(refpoints)[2L] == 2L))
d <- matrix(nrow = nrow(inpoints), ncol = nrow(refpoints))
for (i in seq_along(refpoints)) {
d[, i] <- rowSums(inpoints-refpoints[i,]^2)
}
d
}
`````Again, I want to see the matrix created above with all the points and
distances, how do I call that up (I know this must be simple, but I think
since I can't get the whole shabang to work, I'm having trouble finding the
right command to look at the results.)
Thanks so much by the way, you have an enviable command of R.
-M.
--
View this message in context: http://r.789695.n4.nabble.com/Randomized-Points-in-space-saving-model-results-tp3922612p3954873.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list