R: Function MAPI_CheckData

MAPI_CheckData {mapi} | R Documentation

## Function MAPI_CheckData

### Description

Check the validity of the 'samples' and 'metric' data loaded.
Missing data are removed from 'metric', samples with missing coordinates are removed and samples that are not present in both dataset ('samples' and 'metric') are discarded.

### Usage

    MAPI_CheckData(
      samples,
      metric,
      isMatrix = all((class(metric) == "matrix"), (nrow(metric) == ncol(metric)))
    )

### Arguments

`samples` | a data.frame with names and geographical coordinates of samples. Column names must be: 'ind', 'x', 'y'. Optional column 'errRad' with an error radius for sample locations (eg. GPS uncertainty). Coordinates must be projected (not latitude/longitude).
`metric` | a data.frame or a square matrix with the pairwise metric computed for all pairs of samples. If data.frame, column names must be: 'ind1', 'ind2', 'value'. If matrix, sample names must be the row- and column names.
`isMatrix` | Boolean. Depends on the 'metric' data: TRUE if 'metric' is a square matrix with column names = row names and standing for sample names. FALSE if 'metric is a three columns data.frame ('ind1', 'ind2', 'value'). The default value is determined using a "matrix" class detection for 'metric' as well as identity between row and column number.

### Value

a list of two data.table objects corresponding to 'samples' and 'metric' after cleaning.

### Examples

    ## Not run:
    data("samples")
    data("metric")
    # remove first sample in order to force warning
    samples <- samples[-c(1) , ]
    clean.list <- MAPI_CheckData(samples, metric)
    checked.samples <- clean.list[['samples']]
    checked.metric <- clean.list[['metric']]

    ## End(Not run)

[Package mapi version 1.0.5 Index]