Learn R Programming

spatstat.geom (version 3.2-5)

harmoniseLevels: Harmonise the levels of several factors, or factor-valued pixel images.

Description

Given several factors (or factor-valued pixel images) convert them so that they all use the same set of levels.

Usage

harmoniseLevels(...)

Value

A list, containing the same number of arguments as the input, consisting of factors or factor-valued pixel images.

Arguments

...

Factors, or factor-valued pixel images.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

Details

All of the arguments ... must be factors, or factor-valued pixel images (objects of class "im").

The levels of each factor will be extracted, and combined by taking the union of all the levels. Then each factor will be converted to a new factor so that all of the new factors have exactly the same set of levels.

See Also

levels, levels.im, mergeLevels.

Examples

Run this code
  (a <- factor(sample(letters[1:3], 10, replace=TRUE)))
  (b <- factor(sample(LETTERS[1:4], 7, replace=TRUE)))
  harmoniseLevels(a,b)

  (A <- gorillas.extra$vegetation)
  (B <- gorillas.extra$slopetype)
  harmoniseLevels(A,B)

Run the code above in your browser using DataLab