interpolate_classes: Interpolate data between different classes.

Description Usage Arguments Value Author(s) Examples

View source: R/interpolate_classes.R

Description

Interpolate grain-size data for different classes, either to higher or to lower resolution.

Usage

1
2
interpolate_classes(data, boundaries_in, boundaries_out, method = "natural",
  fixed = TRUE)

Arguments

data

Numeric matrix, input data set with m samples (rows) and n variables (columns).

boundaries_in

Numeric vector, class boundaries of the input data.

boundaries_out

Numeric vector, class boundaries of the output data.

method

Logical scalar, interpolation method, one out of "linear" (linear interpolation), "fmm" (cubic spline), "natural" (natural spline), "periodic" (periodic spline). Default is "natural".

fixed

Logical value, specifying if the outer boundaries should be set to the same values as in the original matrix, default is TRUE. This may become necessary to avoid interpolation errors, see example.

Value

Numeric matrix, interpolated class values.

Author(s)

Michael Dietze

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
## load example data
data(LA950, envir = environment())

## convert units to phi-scale
classes_in <- convert_units(mu = LA950$x)

## Example 1 - decrease the class numbers
## define number of output classes
classes_out <- seq(from = max(classes_in), 
                   to = min(classes_in), 
                   length.out = 20)
                   
## interpolate the data set
Y <- interpolate_classes(data = LA950$y, 
                         boundaries_in = classes_in, 
                         boundaries_out = classes_out,
                         method = "linear")
                         
## show original vs. interpolation for first 10 samples
plot(NA, xlim = range(classes_in), ylim = range(LA950$y))
lines(classes_in, LA950$y)
lines(classes_out, Y, col = 2)

## Example 2 - increase the class numbers
## define number of output classes
classes_out <- seq(from = max(classes_in), 
                   to = min(classes_in), 
                   length.out = 200)

## interpolate the data set
Y <- interpolate_classes(data = LA950$y, 
                         boundaries_in = classes_in, 
                         boundaries_out = classes_out,
                         method = "linear")

## show original vs. interpolation for first 10 samples
plot(NA, xlim = range(classes_in), ylim = range(LA950$y))
lines(classes_in, LA950$y)
lines(classes_out, Y, col = 2)

coffeemuggler/grainsize documentation built on May 24, 2019, 3:06 a.m.