kasc2df {adehabitat} | R Documentation

## Conversion of Objects of Class kasc

### Description

An object of class `kasc` stores several maps in a data frame (one column per variable, and one row per pixel of the raster map). However, the features mapped are rarely rectangle-shaped, whereas the map are inevitably rectangles. Therefore, a lot of pixels of the maps do not contain data. The pixels of the map that do not contain data are `NA` in this data frame. `kasc2df` will "clean" the object of class `kasc` from these NAs, and will return a data frame containing only mapped values that can be used in subsequent analysis.
After these analyses, `df2kasc` may be used to convert the modified data frame to an object of class `kasc` for mapping (e.g. for maps of factorial axes, using `dudi` analyses, see `help(dudi)`).

### Usage

    kasc2df(x, var = names(x))
    df2kasc(df, index, x)

### Arguments

`x` | an object of class `kasc` in `kasc2df` an object of class `kasc` or `mapattr` in `df2kasc`
`var` | a character vector. The names of the variables in the `kasc` that are to be kept in the output
`df` | a data frame resulting of a computation of the component `tab` of the list previously returned by the `kasc2df` (see section `Value` below). This computation may be any form of analysis (Principal component analysis, modelling techniques, etc.)
`index` | an integer vector giving the position of the rows of `df` in the returned `kasc` (such an index can be computed using `kasc2df`)

### Value

`kasc2df` returns a list with the following components:

`tab` | a data frame without NAs, with a number of variables equals to `length(var)`.
`index` | a vector of indices of the rows of the `kasc` kept for the analyses (that is, not `NA`).

`df2kasc` returns an object of class `kasc`.

### Author(s)

Clément Calenge calenge@biomserv.univ-lyon1.fr

### See Also

`as.kasc` for additional information on objects of class `kasc`.

### Examples

    data(puechabon)
    kasc <- puechabon$kasc

    # Display the kasc object
    image(kasc)

    # Preparation for Principal component analysis
    x <- kasc2df(kasc)
    x$tab <- x$tab[, (names(x$tab) != "Aspect")]

    # Principal component analysis
    ana <- dudi.pca(x$tab, scannf = FALSE)

    s.arrow(ana$co)
    s.label(ana$li, clab = 0)

    ## Map of the scores of the rows
    scores <- df2kasc(ana$li, x$index, kasc)
    image(scores)

[Package adehabitat version 1.3 Index]