[R] Applying a loop with rnorm() to eliminate duplicate coordinates in a dataframe object

Ricardo Bandin rbandin at gmail.com
Wed Nov 5 20:19:25 CET 2008


Dear colleagues

I found duplicate coordinates trying to convert a dataframe object (see the
attached file) into a geodata one ('geoR' package is needed). My dataframe
object consists of 2 columns with UTM geographical coordinates and a 3rd
column with fish densities .

To overcome the handicap I must add a tiny value generated by rnorm() to
each geographical coordinate. And it must be in a loop, otherwise the added
value will be the same for all the coordinates, persisting the duplicates.
The example given to me was:
for (i in 1: length(x$coords[1]) { x$coords[1]+rnorm(1,0,1) }

But I still can not understand this instruction syntaxis. I'll be very
grateful if somebody can teach me.

Thanks for your attention,

-- 
Ricardo Bandin Llanos
rbandin en udec.cl
Estudiante - Magíster Cs. m. Pesquerías
Universidad de Concepción, Región del Bio-Bio, Chile
Celular: (0056-41) 97949957


More information about the R-help mailing list