[R-sig-Geo] add random fluctuation x and y coordinates

Agustin Lobo Agustin.Lobo at ija.csic.es
Wed Oct 17 09:51:35 CEST 2007


I've you use runif:

 > options(digits=11)
 > v1 <- c(428381.60000, 428871.60000, 408027.20000, 406870.40000)
 > v1
[1] 428381.6 428871.6 408027.2 406870.4
 > v1+r
[1] 428381.59167 428871.60388 408027.19276 406870.39058

I've you use jitter:
 > jitter(v1,0.01)
[1] 428382.48671 428872.43348 408026.50774 406869.64816

Agus

Eva Kaiserseder escribió:
> Dear List,Sorry for posting again the same question but up to now not all things are clear.
> I've got a point pattern and a few events have duplicated coordinates. In this way I want to add a minimal random fluctuation in the x and y direction/coordinates. If I use the jitter-function my fluctuations are too large. So I tried to control it with the amount argument, but I can't find a solution. How can I restrict them to the decimal places?Thanks a lot for your help!Best regards, Eva
> I tried something like this, to add fluctuation after the second decimal place:
> v1 <- c(428381.6, 428871.6, 408027.2, 406870.4)
> v2 <- c(293884.6, 292929.8, 292621.0, 292014.1)
> test <- as.data.frame(cbind(v1, v2))
> colnames(test) <- c("x", "y")
> coordinates(test) <- c("x","y")
> # ? ? ? ? ?
> r <- runif(length(v1), -0.01, 0.01)
> jitter(test$x, amount = test$x + r)
> jcoord <- cbind(jitter(test[,1], amount = test[,1] + r), jitter(test[,2], amount = test[,2] + r))
>  
> _________________________________________________________________
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster




More information about the R-sig-Geo mailing list