adehabitat (version 1.8.20)

convnum: Conversion from Factor to Numeric for Raster Map

Description

The objects of class kasc may contain maps of type "numeric" (e.g. the elevation) or of type "factor" (e.g. the type of vegetation). With convnum, factor maps are transformed into a collection of k maps of type "numeric" (where k is the number of levels of the factor), with zero means and unit variance (see dudi.mix in the ade4 package for further details). Additionaly, maps of type "numeric" are also centered and scaled (see dudi.mix in the ade4 package for further details).

Usage

convnum(kasc)

Arguments

kasc

an object of class kasc

Value

Returns a list with the following components:

kasc

an object of class kasc

weight

the weights associated with each map of the object kasc, so that the collection of maps defining a categorical variable has the same weight as a numeric variable (see examples).

See Also

dudi.mix (package ade4), kasc

Examples

Run this code
# NOT RUN {
## loads the data
data(puechabon)
kasc <- puechabon$kasc
image(kasc)

## scales all the variables
toto <- convnum(kasc)
image(toto$kasc)

## the Aspect has four levels:
## four variables have been defined.
toto$weight

## The sum of the weights given to each
## level of aspect is equal to:
toto$weight[2:5]
sum(toto$weight[2:5])

## The same weight is therefore given to the factor variable Aspect and
## to any continuous variable, e.g. the elevation.

# }

Run the code above in your browser using DataCamp Workspace