R: Jitters (duplicated) coordinates.

jitterDupCoords {geoR} | R Documentation

## Jitters (duplicated) coordinates.

### Description

Jitters 2D coordinates uniformily on a region around (duplicated) points.

### Usage

    jitter2d(coords, max, min = 0.2 * max, fix.one = TRUE,
             which.fix = c("random", "first", "last"))

    jitterDupCoords(x, ...)

    ## Default S3 method:
    jitterDupCoords(x, ...)

    ## S3 method for class 'geodata'
    jitterDupCoords(x, ...)

### Arguments

`x, coords` | a matrix or data frame with 2D coordinates or geodata object.
`max` | numeric scalar defining maximum jittering distance.
`min` | numeric scalar defining minimum jittering distance.
`fix.one` | logical. Whether or not one of the coordinates should not be jittered.
`which.fix` | single element vector of integer or character, defining which coordinate won't be jittered. Only used if `fix.one=TRUE`.
`...` | arguments passed to `jitter2d`.

### Value

`jitter2d` returns an object of the same type fo the input with jittered values

`jitterDupCoords` returns an object of the same type fo the input with jittered coordinate values only at the duplicated locations

### Author(s)

Paulo Justiniano Ribeiro Jr. paulojus@leg.ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.

### See Also

`dup.coords`, `duplicated.geodata` for functions identifying duplicated locations.

### Examples

    ## simulating data
    dt <- grf(30, cov.p=c(1, .3))
    dt$coords <- round(dt$coords, dig=2)
    ## "forcing" some duplicated locations
    dt$coords[4,] <- dt$coords[14,] <- dt$coords[24,] <- dt$coords[2,]
    dt$coords[17,] <- dt$coords[23,] <- dt$coords[8,]

    ## jittering a matrix of duplicated coordinates
    dt$coords[c(2,4,14,24),]
    jitter2d(dt$coords[c(2,4,14,24),], max=0.01)

    ## jittering only the duplicated locations and comparing with original
    cbind(dt$coords, jitterDupCoords(dt$coords, max=0.01))

    ## creating a now geodata object jittering the duplicated locations of the original one:
    dup.coords(dt)
    dt1 <- jitterDupCoords(dt, max=0.01)
    dup.coords(dt1)

[Package geoR version 1.7-5.2 Index]